Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save congdanhqx-zz/6864740 to your computer and use it in GitHub Desktop.
Save congdanhqx-zz/6864740 to your computer and use it in GitHub Desktop.
public static class TypeExtensions
{
/// <summary>
/// Determine whether a type is simple (String, Decimal, DateTime, etc)
/// or complex (i.e. custom class with public properties and methods).
/// </summary>
/// <see cref="http://stackoverflow.com/questions/2442534/how-to-test-if-type-is-primitive"/>
public static bool IsSimpleType(
this Type type)
{
return
type.IsValueType ||
type.IsPrimitive ||
type == typeof(string) ||
Convert.GetTypeCode(type) != TypeCode.Object;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment