c# implicit constructor code example
Example 1: c# class constructor
public class MyClass
{
public readonly int var1;
public readonly string var2;
public MyClass(int param1, string param2)
{
var1 = param1;
var2 = param2;
}
}
MyClass Class1 = new MyClass(10, "Hello, World!");
MyClass Class2 = new MyClass(9999, "This is the second object!");
Console.WriteLine(Class1.var1);
Console.WriteLine(Class2.var2);
Example 2: c# base class without empty constructor
class A
{
public A(int x, int y)
{
}
}
class A2 : A
{
public A2() : base(1, 5)
{
}
public A2(int x, int y) : base(x, y)
{
}
public A2(int x, int y)
{
}
}