473,414 Members | 1,594 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

What does private short? units; mean?

I have this in some sample code

private short? units;

What does the '?' mean? I've only seen '?' as an operator.
Jul 11 '06 #1
3 2059
That is the short form of a Nullable type. It's the same as:

private Nullable<shortunits;

It's a Nullable structure that contains a short value and a flag that
determines if the structure contains a valid value or not. The variable
can be assigned a null value:

units = null;

Or a short value:

units = 42;

The HasValue property determines if the structure contains a valid value:

if (units.HasValue) {
Console.Write(units.Value);
} else {
Console.Write("n/a");
}

Mr Flibble wrote:
I have this in some sample code

private short? units;

What does the '?' mean? I've only seen '?' as an operator.
Jul 11 '06 #2
* Mr Flibble wrote:
I have this in some sample code

private short? units;

What does the '?' mean? I've only seen '?' as an operator.
OK it's the new C# 2.0 NullableTypes thingy ma-jig.
Jul 12 '06 #3
Mr Flibble <mr********@flibbyly.wobbly.n.etwrote:
* Mr Flibble wrote:
I have this in some sample code

private short? units;

What does the '?' mean? I've only seen '?' as an operator.

OK it's the new C# 2.0 NullableTypes thingy ma-jig.
For more on this, see
http://www.pobox.com/~skeet/csharp/c.../nullable.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jul 12 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
86
by: Michael Kalina | last post by:
Because when I asked for comments on my site-design (Remember? My site, your opinion!) some of you told me never to change anything on font-sizes! What do you guys think of that:...
51
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
35
by: Sunil | last post by:
Hi all, I am using gcc compiler in linux.I compiled a small program int main() { printf("char : %d\n",sizeof(char)); printf("unsigned char : ...
8
by: Droopy | last post by:
I am making a managed C++ wrapper for calling legacy C++ code from C#. I don't understand what's wrong with following code : __gc public class SerialBuffer { private: unsigned...
8
by: Sjaakie Helderhorst | last post by:
Hi all, I'm trying to create a class which handles FTP. Knowing little of classes I'm having some trouble making things work. Also having trouble finding the meaning of some error-codes. The code...
4
by: grizggg | last post by:
I have searched and not found an answer to this question. I ran upon the following statement in a *.cpp file in a member function: static const char * const pacz_HTMLContentTypeHeader =...
12
by: Kiamari | last post by:
class, interface, or enum expected DVD CLASS ^ class, interface, or enum expected DVDINVENTORY CLASS ^ HOW DO I FIX THESE TWO ERRORS WITHOUT GETTING OTHER ERRORS???
14
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.