One other question; I am trying to bind it to a data grid
like:
BeerInventory inventory = new BeerInventory();
inventory.Add(new Beer
("Hamms", "Hamms Brewing Co.", 3));
inventory.Add(new Beer
("Budweiser", "Anheuser-Busch", 1000));
inventory.Add(new Beer("Mulholland
Rain", "City Brewers", 113));
button1.Text = inventory[1].name;
dataGrid1.DataSource = inventory;
The grid doesn't show the records.Any idea??
-----Original Message-----
Sefa,
Default properties are BAAAAD. =)
Anyways, the equivalent in C# is by creating an
indexer, like this:
public LineItem this[int index]
{
get
{
return (LineItem) list[index];
}
}
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com
"Sefa Sevtekin" <se******@de.ibm.com.removespam> wrote in
messagenews:0a****************************@phx.gbl... I am trying to create a c# typesafe collection to avoid
typecasting exceptions and to ease binding of grids to
collections. I already did it in VB.NET but couldn't map
it to C#. In VB.NET you need to define a default
property in order to make binding work. It is something similiar
to this:
Default Public ReadOnly Property Item(ByVal index As
Integer) As LineItem
Get
Return CType(list(index), LineItem)
End Get
End Property
As far as I know there is no Default identifier for C#
properties.
Any help would be appriciated!!!
Sefa
.