Tom Knowlton
asked on
What is "int?" ??
In C#:
public int? blue_green_apps { get; set; }
why the "?" after the int?
Not familiar with this syntax.
public int? blue_green_apps { get; set; }
why the "?" after the int?
Not familiar with this syntax.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm not sure how long it's been around, and I'm pretty sure it's part of C# everywhere. There's even a way to do it in Visual Basic as well, but I think the question mark goes after the variable instead.
ASKER
I'm not sure how long it's been around, and I'm pretty sure it's part of C# everywhere. There's even a way to do it in Visual Basic as well, but I think the question mark goes after the variable instead.
Thanks for the follow-up.
Thank you both for your time!
ASKER
Accepted and Assisted solutions are backwards. Not the points, just the distinction of Accepted vs Assisted.
Yes, you can do it in VB by putting the ? after the name of the variable.
But personnally, I do not like that syntax, either in VB or in C#, because it is simply a shortcut to declaring a variable of the Nullable type:
public Nullable<int> blue_green_apps {get; set;}
The result is the same (int? creates a Nullable<int>), but the "standard" declaration makes it easier for everybody to understand what is happening.
But personnally, I do not like that syntax, either in VB or in C#, because it is simply a shortcut to declaring a variable of the Nullable type:
public Nullable<int> blue_green_apps {get; set;}
The result is the same (int? creates a Nullable<int>), but the "standard" declaration makes it easier for everybody to understand what is happening.
ASKER
Is it unique to MVC or is it part of C# everywhere?