Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Properties as both int? and int

Status
Not open for further replies.

tshad

Programmer
Jul 15, 2004
386
US
Is it possible to set up a propery as both an int? for the Get and int for the set?

I am trying to set it up so that the set can recieve either an integer or a null.

Code:
		public int? Data
		{
		 get { return data; }
		 set {
             if (data == null)
             {
                 data = 0;
                 nullData = true;
             }
             else
             {
                 data = value;
                 nullData = false;
             }
             changed = true; 
            }
		}

The problem is that I don't want to have to do something like:

j = temp.Data.Value;

I would rather do:

j = temp.Data.

If I have the int?, I have to do temp.Data.Value.

Thanks,

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top