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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top