本文整理汇总了C#中Course.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Course.ToString方法的具体用法?C# Course.ToString怎么用?C# Course.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Course
的用法示例。
在下文中一共展示了Course.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToStringTestTwoStudents
public void ToStringTestTwoStudents()
{
string name = "Javascript";
Student maria = new Student("Maria Petrova", 12345);
Student petar = new Student("Petar Marinov", 23445);
IList<Student> students = new List<Student>();
Course javascript = new Course(name, students);
javascript.AddStudent(maria);
javascript.AddStudent(petar);
string expected = "Course name Javascript; Student Maria Petrova, ID 12345; Student Petar Marinov, ID 23445; ";
string actual;
actual = javascript.ToString();
Assert.AreEqual(expected, actual);
}
示例2: Course_TestToStringOverride
public void Course_TestToStringOverride()
{
string name = "Java";
Course course = new Course(name);
Student ivan = new Student("Ivan", 11111);
course.AddStudent(ivan);
string expected = "Course name Java; Student Ivan, ID 11111; ";
string actual = course.ToString();
Assert.AreEqual(expected, actual);
}
示例3: TestCourseToString2
public void TestCourseToString2()
{
Course course = new Course("Extreme Programming", "Martin Fowler");
Assert.AreEqual(
"Name = Extreme Programming; Professor = Martin Fowler; Students = { }",
course.ToString(),
"Course.ToString() is not correct.");
}
示例4: TestCourseToString1
public void TestCourseToString1()
{
Course course = new Course("Design Patterns", "Erich Gamma");
Student kentBeck = new Student("Kent Beck");
Student andrewTanenbaum = new Student("Andrew S. Tanenbaum");
course.AddStudent(kentBeck);
course.AddStudent(andrewTanenbaum);
Assert.AreEqual(
string.Format(
"Name = Design Patterns; Professor = Erich Gamma; Students = {{ {0}, {1} }}",
kentBeck,
andrewTanenbaum),
course.ToString(),
"Course.ToString() is not correct.");
}
示例5: ToStringTestTwoStudents
public void ToStringTestTwoStudents()
{
string name = "JavaScript";
Student gosho = new Student("Gosho Goshev", 12345);
Student pesho = new Student("Pesho Peshev", 23445);
IList<Student> students = new List<Student>();
Course javascript = new Course(name, students);
javascript.AddStudent(gosho);
javascript.AddStudent(pesho);
string expected = "Course name JavaScript; Student Gosho Goshev, ID 12345; Student Pesho Peshev, ID 23445; ";
string actual;
actual = javascript.ToString();
Assert.AreEqual(expected, actual);
}
示例6: ToStringTestOneStudent
public void ToStringTestOneStudent()
{
string name = "JavaScript";
Student gosho = new Student("Gosho Goshev", 12345);
IList<Student> students = new List<Student>();
Course javaScript = new Course(name, students);
javaScript.AddStudent(gosho);
string expected = "Course name JavaScript; Student Gosho Goshev, ID 12345; ";
string actual;
actual = javaScript.ToString();
Assert.AreEqual(expected, actual, "Invalid converting student course to string!");
}
示例7: Main
static void Main(string[] args)
{
Console.WriteLine("Create 3 Course objects - each one using a differrent constructor");
Course c = new Course();
Console.WriteLine("Course # 1: {0}", c.ToString());
c.Name = "Computer Basics";
c.DurationInHours = 40;
Console.WriteLine("Course # 1 with data: {0}", c.ToString());
Console.ReadKey();
Course c1 = new Course("HTML", 25);
Console.WriteLine("Course # 2: {0}", c1.ToString());
Console.ReadKey();
Course c2 = new Course("Javascript Basic", "250");
Console.WriteLine("Course # 3: {0}", c.ToString());
Console.ReadKey();
// Console.ReadKey();
}