C# Data Types

  • In C# bool is not convertible to int unlike C or C++
  • Type of information stored in type declaration:

    • Max and min values
    • Permitted operations
    • Members that it contains
    • Storage space
    • Base type it inherits

  • Types stores information into an executable file as meta data
  • We can use var keyword like var limit = 3 for compiler to infer its type.
  • A type conversion that does not cause data loss is performed automatically by the
    compiler. A conversion that might cause data loss requires a cast in the source
  • Custom Types can be created using 4 keywords struct, class, interface and enum
  • Two basic principles of common type system in .NET

    • It follows the principles of inheritance
    • They are broadly divided into either value type or reference type. Types that are
      declared by term struct are value types while types that are declared by the term
      class are reference types. All numeric types are value type. Reference and value
      types have different runtime and compile type behavior.

Leave a Reply

Your email address will not be published. Required fields are marked *