By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,011 Members | 1,000 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,011 IT Pros & Developers. It's quick & easy.

declaring variable

P: n/a
Hello,
I ran across a code snippet with declared a variable like
private Viewport? viewport
I do not understand the use of the ? in the code.
Thanks
Bill
Jun 27 '08 #1
Share this Question
Share on Google+
7 Replies


P: n/a
On Fri, 13 Jun 2008 15:43:36 -0700, billq <bi********@comcast.netwrote:
Hello,
I ran across a code snippet with declared a variable like
private Viewport? viewport
I do not understand the use of the ? in the code.
See "nullable" in the C# documentation. You can also search this
newsgroup for recent threads using the same word. This same basic
question came up very recently, so the thread should not be hard to find
in Google Groups.

And for what it's worth, reviewing the C# guide and reference on MSDN is
often a much better way to learn about the answers to basic language
syntax questions. :)

Pete
Jun 27 '08 #2

P: n/a
billq wrote:
Hello,
I ran across a code snippet with declared a variable like
private Viewport? viewport
I do not understand the use of the ? in the code.
Thanks
Bill
That's the short syntax for:

private Nullable<Viewportviewport

--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #3

P: n/a
And for what it's worth, reviewing the C# guide and reference on MSDN is
often a much better way to learn about the answers to basic language
syntax questions. :)
What would you search for? :-)

--
Pete
=========================================
I use Enterprise Core Objects (Domain driven design)
http://www.capableobjects.com/
=========================================
Jun 27 '08 #4

P: n/a
Peter Morris wrote:
>And for what it's worth, reviewing the C# guide and reference on MSDN is
often a much better way to learn about the answers to basic language
syntax questions. :)

What would you search for? :-)
For symbols and what could be reserved words I would search for the C#
syntax reference and go from there.

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
Jun 27 '08 #5

P: n/a
I was looking forward to someone suggesting to search for "?" :-)

--
Pete
=========================================
I use Enterprise Core Objects (Domain driven design)
http://www.capableobjects.com/
=========================================
Jun 27 '08 #6

P: n/a
I was looking forward to someone suggesting to search for "?"
;-p

Reminds me of a vendor we used to use; the name? "Click". Try
searching for that!

Marc
Jun 27 '08 #7

P: n/a
On Sun, 15 Jun 2008 02:12:45 -0700, Peter Morris <mrpmorris at gmail dot
<"com>"wrote:
>And for what it's worth, reviewing the C# guide and reference on MSDN is
often a much better way to learn about the answers to basic language
syntax questions. :)

What would you search for? :-)
Note that I didn't write "search". I wrote "reviewing". Obviously a
typographical character like '?' isn't going to be a suitable target for a
search. But that's not to say that there's no way to find the answer to
the original question using the documentation.

As an example, with respect to the original question, one thing someone
might try rather than posting a basic syntax question to the newsgroup
would be to actually _write_ some code like that and see what it does.
They can use the typeof() operator to get the actual type and then write
the type name as a string, or they could just look at the variable itself
in the debugger. Either way they'd probably get enough information to
realize that the section in the documentation named "Nullable Types (C#
Programming Guide)", which is listed among the top-level topics in that
guide, would be a useful one to review. :)

It's not that I object to those questions being asked, nor to answering
them myself (obviously). It's just that these kinds of questions come up
more often than I think they should, and that I also believe that people
will find that if they are a bit more creative than just using the
"Search" box, they can answer many more of the more basic questions
themselves than they realize they are capable of answering.

Pete
Jun 27 '08 #8

This discussion thread is closed

Replies have been disabled for this discussion.