Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to identify if a Type is a custom struct?

For a Type, there is a property IsClass, but how to know a Type is a struct?

Sorry, I have to add some more information.

  1. I am using C#.
  2. Although IsValueType is a necessary condition, it is obviously not enough. For an Integer is a value type also.
like image 567
Ying Avatar asked Feb 18 '10 13:02

Ying


1 Answers

t.IsValueType && !t.IsPrimitive && !t.IsEnum;
like image 81
Jon Hanna Avatar answered Sep 23 '22 08:09

Jon Hanna