12

Possible Duplicate:
C# Language: generics, open/closed, bound/unbound, constructed

While doing some stuff with reflection in C#, I've noticed that some types have the type definition e.g.

Foo<,>

What is the official term for this notation?

Community
  • 1
  • 1
  • 7
    @JohnSaunders I wouldn't call this a duplicate. I'm asking "What is `Foo<,>` called?" whereas he's asking "What's an unbound generic type?" There's no way I would have found his question on Google without already knowing the name. –  Nov 28 '12 at 03:29
  • To my mind, that makes it a duplicate which should not be deleted. – John Saunders Nov 28 '12 at 03:32
  • a more closely related link: [if-at1-t2-is-a-template-for-actual-type-then-why-is-typeofa-allowed](http://stackoverflow.com/questions/3220480/if-at1-t2-is-a-template-for-actual-type-then-why-is-typeofa-allowed?lq=1) – nawfal May 14 '13 at 04:58

2 Answers2

11

Type names which are missing generic parameters such as List<> are referred to as unbound generic types. This question has a good summary of unbound generic types as well as some related terminology.

Depending on what context you are describing these types, some other terminology may be used. The C# specification uses the term "unbound generic type" to refer to something like T<>. The .Net framework seems to prefer the terms "generic type definition" (as dasblinkenlight pointed out, see also Type.GetGenericTypeDefinition()) or "open generic type" (see this article).

Community
  • 1
  • 1
Wesley Wiser
  • 9,491
  • 4
  • 50
  • 69
3

This is a type that represents a generic type definition:

 var genType = typeof(Foo<int,int>);
 var genTypeDef = genType.GetGenericTypeDefinition(); // Returns typeof(Foo<,>)
Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
  • Is *generic type definition* a synonym of *unbound generic types*? –  Nov 28 '12 at 03:20
  • @Bringer128 The two are related: the generic type definition is the term used in the reflection to describe `System.Type` objects corresponding to unbounded generic types. – Sergey Kalinichenko Nov 28 '12 at 03:36