Description of the role of c nullable types

  • 2020-06-03 08:10:01
  • OfStack

Nullable types are mainly used to read data from the database that may be null, rather than for insertion, which is validated, or DBNull.value if you want to insert null into the database

Determines whether the retrieved data is null in the database and, if so, assigns the Lockdatatime attribute of the nullable datetime type

tseat.Lockdatatime = reader.IsDBNull(5) ? null : (DateTime?)reader.GetDateTime(5);

Determines whether the retrieved data is null in the database and, if so, assigns the Testint attribute of the nullable int type

tseat.Testint = reader.IsDBNull(6) ? null : (int?)reader.GetInt32(6);


Related articles: