DOES MEMORY ALLOCATION DONE ON VARIABLE INITIALIZATION OR DECLARATION IN C# IF IT HAPPENS ON DECLARATION IF WE DIDNT USE THE VARIABLE THEN THERE WILL

  • Thread starter Thread starter BULLISWAMY
  • Start date Start date
B

BULLISWAMY

Guest
CLASS A{

int a;//does memory allocation done on declaration

int b=10;//or does it happens on initialization

public static void main(string[ ] args){

A u=new A();

Console.WriteLine(u.b);//it will give 10

//it wastes the memory as a is not used but memory is allocated for it

}

}

Continue reading...
 
Back
Top