Discussion :: Classes and Objects - General Questions (Q.No.11)
|Bhavin said: (Oct 3, 2012)|
|The condition is that this lines must be withing some function or constructor otherwise you can not use i.ToString(); on an instance member directly in class code.|
|Cala said: (Oct 5, 2012)|
|This code is incomplete, no constructor, no referencing and conversion can not be made so explicit.|
|Arun said: (May 26, 2013)|
|myInt = new int(); // Invoke default constructor for int type.
This statement is equivalent to the following statement:
myInt = 0; // Assign an initial value, 0 in this example.
Using the new operator calls the default constructor of the specific type and assigns the default value to the variable. The default value of an integer is 0 BTW.
The difference is that you can't initialize and set anything but the default value value using the new operator.
|Savant said: (Mar 14, 2017)|
|It is perfect code snippet which creates the //default constructor//.|
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.