Solved

int? ??

Posted on 2013-02-06
3
357 Views
Last Modified: 2013-02-06
Hi:

Can someone help me make sense of the following  c# code, please?

int myint = myvar as int? ?? 0;
0
Comment
Question by:sdc248
3 Comments
 
LVL 22

Accepted Solution

by:
p_davis earned 250 total points
ID: 38860312
int myint = myvar as int? ?? 0;

int? is a nullable variable the ?? checks for null and if it is the value returned is 0
0
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 250 total points
ID: 38860326
It means if myvar is null then it is converted to zero when assigned to myint
(if myvar is null then myint = 0)
0
 

Author Closing Comment

by:sdc248
ID: 38860352
Thanks, guys.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question