Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Now I'm stumped
Message
De
01/05/2006 08:56:48
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
29/04/2006 19:05:29
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Divers
Thread ID:
01117847
Message ID:
01117988
Vues:
15
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform