Assignment of object question

  • Thread starter Thread starter RA
  • Start date Start date
R

RA

Hi

If I am writing the following:

DataTable globaldt = new DataTable ();

func ()
{
DataTable dt;

dt = globaldt;

}

Is this statement creating a new copy of the globaldt, or will dt point to
globaldt so that every change in dt will show also in the globaldt?


Thanks,
Ronen
 
Depending on if DataTable is a structure or class, the answer varies.

Structures are value types and a copy is made. Class are ref types - a
reference is made.

-vJ
 
Back
Top