Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.