Chapter 5: Creating and Building Projects | 127 |
If you’re using C# when you do this, VS will ask if you want to change the class filename from Class1 to Student. VB will make the class name change automatically, without asking. This is a convenient way to keep your classes and filenames in sync. It is common to create only one class per file. Listing
Listing 5-1 Class library code
C#:
using System;
using System.Collections.Generic; using System.Linq;
using System.Text;
namespace ClassLibraryDemo
{
public class Student
{
public List<int> GetStudentGrades(string studentName)
{
return new List<int> { 80, 100, 95 };
}
}
}
VB:
Public Class Student
Public Function GetStudentGrades(ByVal studenName As String) As List(Of Integer)
Dim intList As New List(Of Integer) intList.Add(80) intList.Add(100) intList.Add(95)
Return intList End Function
End Class
The important parts of Listing