This is generally the case in the constructor overloads of a class.
Public classA {inti = A; intII; stringstr ="h"; stringSTRR; PublicA () {i= A; STR="h"; } PublicAintx) {i=x; } }
But what's generated is not like this:
Public classA {inti = A; intII; stringstr ="h"; stringSTRR; PublicA () {//The contents of the following comments are compiler-generated operations://i = 0; //II = 0; //Str=null; //STRR = null; //call the constructor of the base class (object Class)I= A; STR="h"; } PublicAintx) {//The contents of the following comments are compiler-generated operations://i = 0; //II = 0; //Str=null; //STRR = null; //call the constructor of the base class (object Class)I=x; } }
This will cause the code to swell ... The solution is the following code
Public classA {inti = A; intII; stringstr ="h"; stringSTRR; PublicA () {i= A; STR="h"; } PublicAintx): This()//Following this method overloads{i=x; } }
Proper overloading of constructors (constructors)------class