当前位置: 首页>>代码示例>>C#>>正文


C# Course.ToString方法代码示例

本文整理汇总了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);
 }
开发者ID:krumov,项目名称:telerik,代码行数:14,代码来源:CourseTest.cs

示例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);
        }
开发者ID:nzhul,项目名称:TelerikAcademy,代码行数:13,代码来源:Course.Tests.cs

示例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.");
        }
开发者ID:Ivan-Dimitrov-bg,项目名称:.Net-framework,代码行数:9,代码来源:CourseTests.cs

示例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.");
        }
开发者ID:Ivan-Dimitrov-bg,项目名称:.Net-framework,代码行数:18,代码来源:CourseTests.cs

示例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);
 }
开发者ID:nikolay-radkov,项目名称:Telerik-Academy,代码行数:14,代码来源:CourseTests.cs

示例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!");
 }
开发者ID:nikolay-radkov,项目名称:Telerik-Academy,代码行数:12,代码来源:CourseTests.cs

示例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();
        }
开发者ID:gailhedberg,项目名称:OOP_OverridingBasics,代码行数:21,代码来源:Program.cs


注:本文中的Course.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。