What is the difference between value types and primitive types?

user1678517 picture user1678517 · Oct 1, 2012 · Viewed 11k times · Source

Reading a book about C# I noticed that sometimes is mentioned value type and sometimes primitive type for some data type (e.g. int, double). I thought they were the same thing, but they are really the same or not?

What is the difference between a value type and a primitive type? Are they the same thing?

EDIT

The question is not only related to C# programming Language, I was wondering how them are different even in any other language.

Answer

D Stanley picture D Stanley · Oct 1, 2012

A primitive type (e.g. int) can be mapped directly to a Base Class Library (BCL) type (e.g. System.Int32)

A value type inherits from System.ValueType and is passed by value (among other properties).

They are not interchangeable as object (System.Object) is a primitive type but not a value type, and structs are value types but not primitive.

See more differences here