Nullable

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hi!

I have two question:
My first question is if these two example names 1 and 2 below are the same.
My second question is if it's enought to just write private DateTime?
mAnniversary
1. private DateTime? mAnniversary = new Nullable<DateTime>();
2. private Nullable<DateTime> mAnniversary = new Nullable<DateTime>();

//Tony
 
Tony said:
Hi!

I have two question:
My first question is if these two example names 1 and 2 below are the same.

Yes. You could have easily figured that out yourself just by "hovering"
the mouse cursor over the variable name in Visual Studio and seeing the
type name for both.
My second question is if it's enought to just write private DateTime?
mAnniversary

Enough for what? At the very least, you need a semicolon for the
declaration. But you don't need to initialize the variable in the
declaration, if that's what you're asking. Class member fields are
initialized to their default value by default.

Pete
 
I have two question:
My first question is if these two example names 1 and 2 below are the same.

Yes.

http://msdn.microsoft.com/en-us/library/2cf62fcy.aspx explains it.
My second question is if it's enought to just write private DateTime?
mAnniversary
1. private DateTime? mAnniversary = new Nullable<DateTime>();
2. private Nullable<DateTime> mAnniversary = new Nullable<DateTime>();

Yes.

If you give it a value later.

Arne
 
Tony Johansson said:
Hi!

I have two question:
My first question is if these two example names 1 and 2 below are the same.
My second question is if it's enought to just write private DateTime?
mAnniversary
1. private DateTime? mAnniversary = new Nullable<DateTime>();
2. private Nullable<DateTime> mAnniversary = new Nullable<DateTime>();

Yes and yes.
 
Back
Top