Nullable

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
 
P

Peter Duniho

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
 
A

Arne Vajhøj

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
 
J

J.B. Moreno

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.
 

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

Top