本文整理汇总了C#中System.Enum.GetTypeCode方法的典型用法代码示例。如果您正苦于以下问题:C# Enum.GetTypeCode方法的具体用法?C# Enum.GetTypeCode怎么用?C# Enum.GetTypeCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Enum
的用法示例。
在下文中一共展示了Enum.GetTypeCode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add
public void Add(Enum e)
{
int val = (int)Convert.ChangeType(e, e.GetTypeCode());
string t = e.GetType().Name;
if (!enums.ContainsKey(t))
enums.Add(t, new SortedList<int, int>());
SortedList<int, int> values = enums[t];
values.Add(val, ++uniqValue);
}
示例2: Lookup
public int Lookup(Enum e)
{
int val = (int)Convert.ChangeType(e, e.GetTypeCode());
string t = e.GetType().Name;
if (!enums.ContainsKey(t))
return -1;
if (!enums[t].ContainsKey(val))
return -1;
return enums[t][val];
}
示例3: EvaluateEnum
private static void EvaluateEnum(Enum e)
{
Console.WriteLine(String.Format("Information about {0}", e.GetType().Name));
Console.WriteLine(String.Format("Underlying type: {0}", e.GetTypeCode()));
var enumData = Enum.GetValues(e.GetType());
foreach (var item in enumData)
{
Console.WriteLine(String.Format("Name: {0} Value: {0:d} ", item));
}
Console.WriteLine();
}
示例4: ValidateEnumType
public static bool ValidateEnumType(Enum enumToValidate)
{
if (enumToValidate.GetTypeCode() != TypeCode.Int32)
throw new Exception("Invalid Enum Type");
return true;
}
示例5: ValidateEnumType
/// <summary>
/// Internal function to validate the enumerator is of type Int32
/// </summary>
/// <param name="enumToValidate"></param>
/// <exception cref="WebDavException">Throw exception if the enumToValidate value is not a valid Int32</exception>
internal static bool ValidateEnumType(Enum enumToValidate)
{
if (enumToValidate.GetTypeCode() != TypeCode.Int32)
throw new WebDavException(InternalFunctions.GetResourceString("InvalidEnumIntType"));
return true;
}
示例6: GetTypeCode
public static void GetTypeCode(Enum e, TypeCode expected)
{
Assert.Equal(expected, e.GetTypeCode());
}
示例7: AddAsset
/// <summary>
/// Adds an asset
/// </summary>
/// <param name="name"></param>
/// <param name="CreateCallback"></param>
/// <param name="scale"></param>
public void AddAsset(Enum e, GetGobjectDelegate CreateCallback, Vector3 scale)
{
int id = (int)Convert.ChangeType(e, e.GetTypeCode());
AddAsset(new Asset(id, CreateCallback, scale));
}
示例8: GetNewInstance
/// <summary>
/// returns an instance of the specified asset type
/// </summary>
/// <param name="e"></param>
/// <param name="owningClientId"></param>
/// <returns></returns>
public Gobject GetNewInstance(Enum e, int owningClientId)
{
int id = (int)Convert.ChangeType(e, e.GetTypeCode());
return GetNewInstance(id, owningClientId);
}