2
Answers

NP54 Declaring different way

Maha

Maha

17y
2k
1

Hi Guys

 

NP54   Declaring  different way 

 

I wish to know is there any difference in declaring a variable in different way for example:

 

int x;

 

Same variable is declared in different way

int x = new int();

 

The article in the following website give rise to this question. Anyone knows please explain.

 

http://www.c-sharpcorner.com/UploadFile/rmcochran/csharp_memory01122006130034PM/csharp_memory.aspx

 

Thank you

 

This implimention is in the article

 

public int ReturnValue()
{
         int x = new int();
         x = 3;
         int y = new int();
         y = x;      
         y = 4;         
         return
x;
}

 

Answers (2)