C#-构造函数

    xiaoxiao2025-08-05  22

    如果有了新的构造函数就不能调用默认的构造函数了

    class Student { public Student(String str) { Console.WriteLine(str); } public Student() { Console.WriteLine("默认构造函数"); } } static void Main(string[] args) { Student stu = new Student(); Student stu1 = new Student("新构造函数"); Console.ReadKey(); }

    最新回复(0)