Need help converting VB Implements to C# Code

J

Jay Douglas

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.Count
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.Collections.IEnumerable.GetEnumerator

Return New StudentEnumerator( m_students )

End Function

End Class
 
D

Daniel O'Connell

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

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

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

public IEnumerator GetEnumerator()
{
return m_students.GetEnumerator();
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top