How to determine if a .NET Type is a custom struct?

Posted by SztupY on Stack Overflow See other posts from Stack Overflow or by SztupY
Published on 2010-04-26T13:43:54Z Indexed on 2010/04/26 13:53 UTC
Read the original article Hit count: 263

Filed under:
|
|
|
|

Hi!

How to write a simple method, that checks whether a concrete type is a custom struct (created with public struct { };) or not.

Checking Type.IsValueType is not enough, because it is also true to int, long, etc, and adding a check to !IsPrimitiveType won't exclude decimal, DateTime and maybe some other value types. I know that most of the built in value types are actually "structs", but I only want to check for "custom structs"

These questions are mostly the same but without the answer I need:

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET