本文整理汇总了C#中Class.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Class.ToString方法的具体用法?C# Class.ToString怎么用?C# Class.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Class
的用法示例。
在下文中一共展示了Class.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create_Class
public void Create_Class()
{
var @class = new Class("Create_Class");
var expected = Comparer.Create_Class();
var actual = @class.ToString();
Assert.AreEqual(expected, actual);
Console.WriteLine(actual);
}
示例2: Create_Class_With_Properties
public void Create_Class_With_Properties()
{
var @class = new Class("Create_Class_With_Properties")
.AddMembers(new Property("Boolean", "Property_1"))
.AddMembers(new Property(typeof(Int32), "Property_2"));
var expected = Comparer.Create_Class_With_Properties();
var actual = @class.ToString();
Assert.AreEqual(expected, actual);
Console.WriteLine(actual);
}
示例3: Create_Class_With_Method_Block
public void Create_Class_With_Method_Block()
{
var @class = new Class("Create_Class_With_Methods")
.AddMembers(new Field("Field_1"))
.AddMembers(new Method(nameof(Int32), "Method_2"));
var expected = Comparer.Create_Class_With_Methods();
var actual = @class.ToString();
Assert.AreEqual(expected, actual);
Console.WriteLine(actual);
}
示例4: Main
static void Main()
{
IList<Student> students = new List<Student>
{
new Student("Георги Пешев", 1),
new Student("Димитър Иванов", 2),
new Student("Иван Цветанов", 5),
new Student("Гергана Зафирова", 3),
new Student("Стела Маринова", 4)
};
var html = new Discipline("HTML", 6);
html.AddStudent(students[0]);
html.AddStudent(students[2]);
html.AddStudent(students[4]);
html.Ditails = "Вечерни курсове";
var css = new Discipline("CSS", 5);
css.AddStudent(students[0]);
css.AddStudent(students[1]);
css.AddStudent(students[2]);
var java = new Discipline("Java", 4);
java.AddStudent(students[1]);
java.AddStudent(students[3]);
java.AddStudent(students[4]);
var javaScript = new Discipline("JavaScript", 5,students);
var webDevelopmentTeacher = new Teacher("Владимир Георгиев");
webDevelopmentTeacher.AddDiscipline(html);
webDevelopmentTeacher.AddDiscipline(css);
webDevelopmentTeacher.AddDiscipline(javaScript);
var JavaDevelopmentTeacher = new Teacher("Тодор Куртев");
JavaDevelopmentTeacher.AddDiscipline(java);
var classA = new Class("A", new List<Teacher> { webDevelopmentTeacher, JavaDevelopmentTeacher });
string str = classA.ToString();
Console.WriteLine(classA);
}