<分区>
Possible Duplicate:
How can I get the primitive name of a type in C#?
我在 C# 中有以下代码:
Assembly sysAssembly = 0.GetType().Assembly;
Type[] sysTypes = sysAssembly.GetTypes();
foreach (Type sysType in sysTypes)
{
if (sysType.IsPrimitive && sysType.IsPublic)
Console.WriteLine(sysType.Name);
}
这段代码输出:
Boolean, Byte, Char, Double, Int16, Int32, Int64, IntPtr, SByte, Single, UInt16, UInt32, UInt64, UIntPtr,
如果可能的话,我想用 bool
替换 Boolean
,用 byte
替换 Byte
等等,没有依赖固定的数组或字典。有办法做到这一点吗?