General information
Category:
The Mere Mortals .NET Framework
Thanks Cetin,
That clears things up quite a bit. Coming from a VFP background, I'm finding C# not so difficult, but there are some subtleties that go over my head.
>>Forgive me, but I am but a complete newbie to .NET. Most of the syntax I can figure out on my own, but this one has me really puzzled: this.GetOrderDetail((int?)e.PrimaryKeyValue);
>>
>>Why is int? in parens? Why is there a question mark after int? Am I confusing anybody else besides myself?
>>
>>I'm going to go out on a limb here, but I'm guessing that e.PrimaryKeyvalue is being typed as int. Correct me if I'm wrong.
>>
>>Jim
>
>Jim,
>You are coming from VFP so saying it with VFP example might work better.
>Consider you have a new record in buffer. A field's OLDVAL() is null (record is new no valid oldvalue). Also consider it's of type integer.
>
>(int)e.PrimaryKeyValue
>
>casts e.PrimaryKeyValue to an integer. Having ? tells that it could be null.
>
>int? x = null;
>
>would not work if nullable types didn't exist (like it didn't in .Net 1.1). Before you could only use nulls with reference types (ie: string).
>You wouldn't be also able to compare if int x is null (because they were not nullable before).
>
>?? operator lets you check types being null with a shorthand notation. ie: If x is null consider x is 100, else whatever it has the value (VFP: nvl(x,100)):
>
>y = x ?? 100;
>
>Also check Nullable class.
>Cetin
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only