• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 183
  • Last Modified:

Understanding this bit of C# code

The line i'm interested in understanding is just before the for loop:
     sampleClass.Students = new List<StudentData>();

The 2 C# to VB translators I use both choke on that line. It's specific to webservices? What's it look like in VB?

public ClassData GetRoster(int numberOfStudents)
     ClassData sampleClass = new ClassData();
     sampleClass.ClassName = "Science";
     sampleClass.TeacherName = "Smith";
     sampleClass.TeacherID = 10;
     sampleClass.Students = new List<StudentData>();
           for (int i = 0; i < numberOfStudents; i++)
                 StudentData studentOne = new StudentData();
                 studentOne.StudentID = i + 1;
                 student.StudentName = (i%2 == 0 ? "Denis" : "Alexey");
     return sampleClass;
1 Solution
It's not specific to Web services it's just creating an instance of the List Generic Class

Example from MSDN:
        Dim dinosaurs As New List(Of String)
        List<string> dinosaurs = new List<string>();

Your Example in VB.NET would be: -

sampleClass.Students = new List(Of StudentData);

For more info see: -


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now