Basic Question....

  • Thread starter Thread starter Wallace
  • Start date Start date
W

Wallace

Hai all,

Can anyone plz answer my question...
What is the difference between the following

1. DataTable dt = new DataTable();

2. DataTable dt;

and what is the use of each one...

Looking forward for the reply...
 
Wallace said:
Can anyone plz answer my question...
What is the difference between the following

1. DataTable dt = new DataTable();

2. DataTable dt;

and what is the use of each one...

Looking forward for the reply...

Both of them declare a variable called dt, the value of which is always
either a reference to a DataType (or derived type) or null.

In the first case, you're also creating a new DataTable and assigning
the reference to dt.

In the second case, either dt will be unassigned (and can't be read
until it's been definitely assigned) if it's a local variable, or will
have a value of null if it's a member variable.
 
Back
Top