You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
501 B
20 lines
501 B
using System; |
|
using System.Collections.Generic; |
|
using System.Text; |
|
|
|
namespace ReZero |
|
{ |
|
public static class TypeExtensions |
|
{ |
|
public static Type GetNonNullableType(this Type type) |
|
{ |
|
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) |
|
{ |
|
return type.GetGenericArguments()[0]; |
|
} |
|
|
|
// 如果类型不是 Nullable<>,则直接返回原类型 |
|
return type; |
|
} |
|
} |
|
}
|
|
|