Indexer with 2 arguments and interface C# with Example



Indexer with 2 arguments and interface C# with Example

interface ITable { 
// an indexer can be declared in an interface 
object this[int x, int y] { get; set; } 
} 
class DataTable : ITable 
{ 
private object[,] cells = new object[10, 10]; 
///  
/// implementation of the indexer declared in the interface 
///  
///  X-Index 
///  Y-Index 
/// Content of this cell 
public object this[int x, int y] 
{ 
get 
{ 
return cells[x, y]; 
} 
set 
{ 
cells[x, y] = value; 
} 
} 
} 
 

0 Comment's

Comment Form

Submit Comment