Difference between int i=1; vs int? i = 1;

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In C#, what is the difference between declaring an int like this:

int i = 1;

versus

int? i = 1;

both seem to work the same way in VS.NET 2005.
 
Eeraj,

When you say int? it is really an alias in C# for Nullable<int> so:

int? i = 1;

Is the same as:

Nullable<int> i = 1;

Which should explain the difference.

Hope this helps.
 

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