Default constructors
In this chapter you will learn:
Implicit parameterless constructor
C# provides a parameterless constructor if the class has no constructor defined.
The Rectangle
in the following has no
constructors and C# adds Rectangle()
to it.
using System;/* j a v a2 s . c om*/
class Rectangle{
int Width;
int Height;
}
class Program
{
static void Main(string[] args)
{
Rectangle r = new Rectangle();
}
}
Next chapter...
What you will learn in the next chapter:
Home » C# Tutorial » Class