Need help converting VB Implements to C# Code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jay Douglas

    Need help converting VB Implements to C# Code

    I found an example that teaches me how to create my own collections ... but
    the best one that I can find is in VB. I don't know how to convert the VB
    "Implements " in to C# friendly code.. Could someone please help me convert
    the snippet of code or provide a link to a good C# collections tutorial ...
    Thanks.

    -----------------------------------
    Public Class Students
    Implements IEnumerable

    Private m_students As New ArrayList()

    Public Sub New()
    End Sub

    Public ReadOnly Property Count() As Int32
    Get
    Return m_students.Coun t
    End Get
    End Property

    Public Sub AddStudent( ByVal student As Student )
    m_students.Add( student)
    End Sub

    ' Impelementation of IEnumerable
    Public Function GetEnumerator() As IEnumerator _
    Implements System.Collecti ons.IEnumerable .GetEnumerator

    Return New StudentEnumerat or( m_students )

    End Function

    End Class
    ---------------------

    Cheers!

    --
    Jay Douglas
    Fort Collins, CO




  • Daniel O'Connell

    #2
    Re: Need help converting VB Implements to C# Code

    public class Students : IEnumerable
    {
    ArrayList m_students = new ArrayList();
    public Students()
    {
    }

    public int Count
    {
    get
    {
    return m_students.Coun t;
    }
    }

    public void AddStudent(Stud ent student)
    {
    m_students.Add( student);
    }

    public IEnumerator GetEnumerator()
    {
    return m_students.GetE numerator();
    }
    }
    "Jay Douglas" <jaysothernewsa ddress@squarei. com> wrote in message
    news:%2318cM3Po DHA.2500@TK2MSF TNGP10.phx.gbl. ..[color=blue]
    > I found an example that teaches me how to create my own collections ...[/color]
    but[color=blue]
    > the best one that I can find is in VB. I don't know how to convert the VB
    > "Implements " in to C# friendly code.. Could someone please help me[/color]
    convert[color=blue]
    > the snippet of code or provide a link to a good C# collections tutorial[/color]
    ....[color=blue]
    > Thanks.
    >
    > -----------------------------------
    > Public Class Students
    > Implements IEnumerable
    >
    > Private m_students As New ArrayList()
    >
    > Public Sub New()
    > End Sub
    >
    > Public ReadOnly Property Count() As Int32
    > Get
    > Return m_students.Coun t
    > End Get
    > End Property
    >
    > Public Sub AddStudent( ByVal student As Student )
    > m_students.Add( student)
    > End Sub
    >
    > ' Impelementation of IEnumerable
    > Public Function GetEnumerator() As IEnumerator _
    > Implements System.Collecti ons.IEnumerable .GetEnumerator
    >
    > Return New StudentEnumerat or( m_students )
    >
    > End Function
    >
    > End Class
    > ---------------------
    >
    > Cheers!
    >
    > --
    > Jay Douglas
    > Fort Collins, CO
    >
    >
    >
    >[/color]


    Comment

    Working...