>Not sure if I understand correctly the use of constructors.
>
>Is it a way to make sure that a class will always have parameters initialized the right way?
>
>For example if I don't create a constructor and the class has two parameters that should be integers. it could be called with anything as parameters.
>
>But if I create a constructor for that class and I don't specify these parameters then the editor will tell me about my error?
Yes
If you don't specify a constructor without parameters, the IDE will complain - if it is a class
It will not complain if it is a structure, since a structure has a parameterless constructor by default
* COMPLAIN
internal static class Constructor_Test
{
internal static void Go()
{
Constructor c = new Constructor();
}
}
internal class Constructor
{
int X;
int Y;
internal Constructor(int x, int y)
{
X = x;
Y = y;
}
}
&& NO COMPLAINT
internal static class Constructor_Test
{
internal static void Go()
{
Constructor c = new Constructor();
}
}
internal struct Constructor
{
int X;
int Y;
internal Constructor(int x, int y)
{
X = x;
Y = y;
}
}
Gregory