Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question

closed as not constructive by jmort253, Martijn Pieters, MichaelT, Dynamic, JeffO Feb 25 '13 at 1:10

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

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 Feb 24 '13 at 18:10
    
The former. Thanks. –  RW XV Feb 24 '13 at 18:19
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. –  Kate Gregory Feb 24 '13 at 19:20
add comment

2 Answers

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.

share|improve this answer
add comment

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.

share|improve this answer
1  
Actually, it seems that I have been wrong on that statement. typeof(string).IsPrimitive returns false. –  driis Feb 24 '13 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. –  delnan Feb 24 '13 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 Feb 25 '13 at 6:13
add comment

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