[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.mobile

converting code from vb.net to c# please convert

mahendar

11/28/2002 6:55:00 AM

Public Class TradeColl
Inherits System.Collections.CollectionBase
'Indexer
Default Public ReadOnly Property Item(ByVal index As
Integer) As Trade
Get
' The appropriate item is retrieved from the
List object
and
' explicitly cast to the Execution type, then
returned to
the
' caller.
Return CType(List.Item(index), Trade)
End Get
End Property

'Strongly typed Add method
Public Sub Add(ByVal newTrade As Trade)
List.Add(newTrade)
End Sub
End Class


1 Answer

Pedro Veloso

12/4/2002 1:59:00 AM

0

public class TradeColl : CollectionBase
{

public void Add(Trade newTrade)
{
base.List.Add(newTrade);
}

public void Remove(int index)
{
if (index <= base.Count - 1 && index >= 0)
{
base.List.RemoveAt(index);
}
}

public void Remove(string name)
{
for (int i = 0; i < base.Count; i++)
{
if (Item(i)._name == name)
{
Remove(i);
}
}
}

public Trade Item(int index)
{
return (Trade)base.List[index];
}

public Trade Item(string name)
{
IEnumerator iEnumerator = base.List.GetEnumerator();

while (iEnumerator.MoveNext())
{
Trade myTrade = (Trade)iEnumerator.Current;
if (myTrade._name == name)
{
Trade newTrade = myTrade;
return newTrade;
}
}


return null;
}

public string ToXML()
{
string str = "";
str = String.Concat(str, "<Trades>");
IEnumerator iEnumerator = base.List.GetEnumerator();

while (iEnumerator.MoveNext())
{
Trade myTrade = (Trade)iEnumerator.Current;
str = String.Concat(str, myTrade.ToXML());
}


str = String.Concat(str, "</Trades>");
return str;
}
}


"mahendar" <mahendar@hotmail.com> wrote in message
news:1c10801c296a2$ca5658c0$89f82ecf@TK2MSFTNGXA01...
> Public Class TradeColl
> Inherits System.Collections.CollectionBase
> 'Indexer
> Default Public ReadOnly Property Item(ByVal index As
> Integer) As Trade
> Get
> ' The appropriate item is retrieved from the
> List object
> and
> ' explicitly cast to the Execution type, then
> returned to
> the
> ' caller.
> Return CType(List.Item(index), Trade)
> End Get
> End Property
>
> 'Strongly typed Add method
> Public Sub Add(ByVal newTrade As Trade)
> List.Add(newTrade)
> End Sub
> End Class
>
>