declaring variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • billq

    #1

    declaring variable

    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
  • Peter Duniho

    #2
    Re: declaring variable

    On Fri, 13 Jun 2008 15:43:36 -0700, billq <bill.quigg@com cast.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

    Comment

    • =?ISO-8859-1?Q?G=F6ran_Andersson?=

      #3
      Re: declaring variable

      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<Viewpo rtviewport

      --
      Göran Andersson
      _____
      Göran Anderssons privata hemsida.

      Comment

      • Peter Morris

        #4
        Re: declaring variable

        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)

        =============== =============== ===========


        Comment

        • =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?=

          #5
          Re: declaring variable

          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:lasse@vk arlsen.no
          Blogger is a blog publishing tool from Google for easily sharing your thoughts with the world. Blogger makes it simple to post text, photos and video onto your personal or team blog.

          PGP KeyID: 0xBCDEA2E3

          Comment

          • Peter Morris

            #6
            Re: declaring variable

            I was looking forward to someone suggesting to search for "?" :-)



            --
            Pete
            =============== =============== ===========
            I use Enterprise Core Objects (Domain driven design)

            =============== =============== ===========


            Comment

            • Marc Gravell

              #7
              Re: declaring variable

              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

              Comment

              • Peter Duniho

                #8
                Re: declaring variable

                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

                Comment

                Working...