0

I have class that uses a ulong ParentId { get; set; }and I needed it to be nullable. Because if the entity (of this class) is added to the database, and has no parent, it must be null and not 0. So I remembered vaguely something about preceding it with a question mark. And it works. See the code below.

class ExampleClass
{
    public ulong ?ParentId { get; set; }
}

Question: Does anyone know where to find the documentation for this?

Johan
  • 74,508
  • 24
  • 191
  • 319
Mike de Klerk
  • 11,906
  • 8
  • 54
  • 76

2 Answers2

1

You may check Using Nullable Types and Nullable Types

Giannis Paraskevopoulos
  • 18,261
  • 1
  • 49
  • 69
1

For value type which can be nullable - http://msdn.microsoft.com/en-us/library/b3h38hb0.aspx Question mark after a value type is same as Nullable<T>

tray2002
  • 188
  • 6