3

I thought that in .NET types are either value types or reference types. But this guy, when asked about .NET types, talked about "primitive types" and "complex types".

I understand that people sometimes use different names to refer to the same concepts, but isn't it strange that a Microsoft certified professional would use this kind of terminology?

2
  • 2
    Hi and welcome to Programmers SE! Are you asking if it's strange or are you asking for someone to explain the two types to you? I'd suggest an edit to your post to clarify that part, as this question may be considered not constructive with your second paragraph the way it is written. On Programmers SE, questions should be clear to ensure you get the best answers you're looking for. Hope this helps! :)
    – jmort253
    Commented Feb 24, 2013 at 18:10
  • 1
    I removed the Microsoft-certifications tag. Being identified as an MVP is not a certification. It's also possible to be an MVP of something other than .NET programming, such as Windows itself, SQL, XBox, native C++, and so on. Commented Feb 24, 2013 at 19:20

2 Answers 2

15

It's not strange at all. "Primitives" is a bit of standard terminology in the programming world. It means a thing that is not built out of simpler things, but serves as a building block to create more complex things. So "primitive types and complex types" is a completely valid way to talk about them.

It can be used in other contexts as well. For example, synchronization primitives are low-level constructs that are not actually primitive data types, but are still not built out of other synchronization objects, and can be used to build higher-level synchronization objects, such as monitors.

5

First of all: I think this might just be confusing terminology.

Primitive types, value types and reference types are 3 different things:

  • Primitive types are those that are built into the language as a primitive. (int, bool and so on). MSDN often refers to them as just "built in types".
  • Value types are those that are allocated by value on the stack. They include most of the primitive types. The formal definition is all types that derive from System.ValueType; this also includes all structs.
  • Reference types are allocated on the heap and variables of that type are said to be references to the object. It's like pointers from C, but C# takes care of all the type and memory safety for you.

While I haven't seen any formal definition for a "complex type" in C#, I would guess it means all defined types that are not primitives. This includes both value types and reference types.

See more info on types on MSDN.

3
  • 1
    Actually, it seems that I have been wrong on that statement. typeof(string).IsPrimitive returns false.
    – driis
    Commented Feb 24, 2013 at 18:20
  • 2
    Your definition of value types is wrong, and even when corrected, it focuses on the completely wrong aspect. See The Truth About Value Types.
    – user7043
    Commented Feb 24, 2013 at 19:12
  • Value types are value types because an assignment assigns the value, not a (possibly shared) reference to the value. This has nothing to do with whether the value is stored on the heap or the stack, and in fact it can be and is stored in both places. The semanics of a struct (value type) with a single primitive property and a class (reference type) with the same property are drastically different -- assignment and comparision mean entirely different things for the two types.
    – jmoreno
    Commented Feb 25, 2013 at 6:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.