Alex Rivera | Logout

Is String a primitive type?

Asked 2010-10-19T06:13:36.257
79

I am curious about the string and primitive types. Article like this says string is primitive type. However second article on MSDN does not list string as primitive type.

However when I ran the code provided in second article, it displays String is not Primitive type.

Can any one guide me on this?

Edit
Report

1 Answer

53

There is no "Microsoft" definition of what a primitive type is.

There are only definitions of primitive types in a given context.

  • The CLR defines primitive types as being nothing more than:
    • System.Boolean
    • System.Byte
    • System.SByte
    • System.Int16
    • System.UInt16
    • System.Int32
    • System.UInt32
    • System.Int64
    • System.UInt64
    • System.IntPtr
    • System.UIntPtr
    • System.Char
    • System.Double
    • System.Single
  • The VB.NET specification version 10 (in section 7.3) defines "primitive types" as being types that have a keyword alias for the type (thus allowing the usage of that type without importing the System namespace), a way to define instances of that type with a literal; and permitting the use of these types as constants; the primitive types in VB.NET are:
    • System.Byte
    • System.SByte
    • System.UInt16 (UShort)
    • System.Int16 (Short)
    • System.UInt32 (UInteger)
    • System.Int32 (Integer)
    • System.UInt64 (ULong)
    • System.Int64 (Long)
    • System.Single
    • System.Double
    • System.Decimal
    • System.Boolean
    • System.DateTime (Date)
    • System.Char
    • System.String
  • The C# specification (version 4) defines keyword aliases for some types, and a

answered 2012-11-23T13:41:54.780

Your Answer