Created
August 1, 2020 16:37
-
-
Save nanwang2016/715f2b0ff6617b37ebc93ba9c5cf2776 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace TestFile | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
//Only Defaul Constructor with parameters is valid, as Private Constructor is not allowed to create an instance. | |
Student UniStudent = new Student("Jack", "007"); | |
} | |
} | |
public class Student | |
{ | |
//Private Constructor | |
private Student() | |
{ | |
Console.WriteLine("I am a Private Constructor"); | |
} | |
public static string name, studentID; | |
//Default Constructor with parameters | |
public Student(string a, string b) | |
{ | |
name = a; | |
studentID = b; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment