Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. int?

int?

Scheduled Pinned Locked Moved C#
question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    seemamltn
    wrote on last edited by
    #1

    what is the difference between int? and int

    seema

    C J 2 Replies Last reply
    0
    • S seemamltn

      what is the difference between int? and int

      seema

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      int? is shorthand for INullable A nullable type can be null as well as the normal values and has a HasValue property. Very useful, for example, if you have a numeric column in your database which can be null, or just in general to avoid having to have magic numbers to indicate that no value has been set. Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      1 Reply Last reply
      0
      • S seemamltn

        what is the difference between int? and int

        seema

        J Offline
        J Offline
        Judah Gabriel Himango
        wrote on last edited by
        #3

        The question mark denotes it is a nullable value. For example,

        int? i = null;

        is the same as

        Nullable<int> i = null;

        The Nullable<T> type wraps a value type, like integers, but allows you to assign null to them. Without this, you couldn't assign null to an int or any other value type.

        Tech, life, family, faith: Give me a visit. I'm currently blogging about: 3 years of marriage The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups