10

I need to provide a user a list of all primitive types available and was wondering if there is an Enum in the .net library that has all primitive types, so that I don't have to build one.

Vladislav Rastrusny
  • 29,378
  • 23
  • 95
  • 156
epitka
  • 17,275
  • 20
  • 88
  • 141

3 Answers3

14

Not an enum, but:

var primitives = typeof(int).Assembly.GetTypes()
       .Where(type => type.IsPrimitive).ToArray();
Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
12

The nearest you are going to get is System.TypeCode.

Martin Brown
  • 24,692
  • 14
  • 77
  • 122
5

No, there is no such enum.

Maximilian Mayerl
  • 11,253
  • 2
  • 33
  • 40