Got to know a new thing today that we can create integers by using new
operator as below
int num = new int();
Now I wonder if I create an integer in this manner then the resulting integer will be a value type or reference type? I guess it will be a value type. I tried the below code
int num1 = 10;
int num2 = new int();
int num3;
num1 = num2;
num2 = num3;
I got the below build error:
Use of unassigned local variable 'num3'
I know why this build error is given. But I wonder when and how to use new int()
and how exactly does this work? Can anyone please put some light on this?
Thanks & Regards :)