请问关于c的具体应用场景有哪些?

2026-05-23 19:541阅读0评论SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计200个文字,预计阅读时间需要1分钟。

请问关于c的具体应用场景有哪些?

csharpnamespace CutPictureTest{ public class EnumHelper { public static System.Collections.ArrayList GetName(Type enumType) { System.Collections.ArrayList arr=new System.Collections.ArrayList(); string[] n=System.Enum.GetNames(enumType); foreach (string name in n) { arr.Add(name); } return arr; } }}

测试代码如下:

namespace CutPictureTest.Comm { public class EnumHelper { public static System.Collections.ArrayList GetName(Type enumType) { System.Collections.ArrayList arr = new System.Collections.ArrayList(); string[] n = System.Enum.GetNames(enumType); foreach (string item in n) arr.Add(item); return arr; } public static T ToEnum<T>(string strEnum) { T t = (T)Enum.Parse(typeof(T), strEnum); return t; } public static System.Collections.Hashtable EnumToHashtable(Type enumType) { System.Collections.Hashtable ht = new System.Collections.Hashtable(); Array arr = System.Enum.GetValues(enumType); for (int i = 0; i < arr.Length; i++) ht.Add(Convert.ToInt16(arr.GetValue(i)), arr.GetValue(i).ToString()); return ht; } } }

调用方式:

请问关于c的具体应用场景有哪些?

System.Collections.Hashtable arr = Comm.EnumHelper.EnumToHashtable(typeof(tImageFormat)); foreach (string item in arr.Values) cb.Items.Add(item);

其中的cb表示ComboBox对象,你可以替换成你的下拉框对象。

本文共计200个文字,预计阅读时间需要1分钟。

请问关于c的具体应用场景有哪些?

csharpnamespace CutPictureTest{ public class EnumHelper { public static System.Collections.ArrayList GetName(Type enumType) { System.Collections.ArrayList arr=new System.Collections.ArrayList(); string[] n=System.Enum.GetNames(enumType); foreach (string name in n) { arr.Add(name); } return arr; } }}

测试代码如下:

namespace CutPictureTest.Comm { public class EnumHelper { public static System.Collections.ArrayList GetName(Type enumType) { System.Collections.ArrayList arr = new System.Collections.ArrayList(); string[] n = System.Enum.GetNames(enumType); foreach (string item in n) arr.Add(item); return arr; } public static T ToEnum<T>(string strEnum) { T t = (T)Enum.Parse(typeof(T), strEnum); return t; } public static System.Collections.Hashtable EnumToHashtable(Type enumType) { System.Collections.Hashtable ht = new System.Collections.Hashtable(); Array arr = System.Enum.GetValues(enumType); for (int i = 0; i < arr.Length; i++) ht.Add(Convert.ToInt16(arr.GetValue(i)), arr.GetValue(i).ToString()); return ht; } } }

调用方式:

请问关于c的具体应用场景有哪些?

System.Collections.Hashtable arr = Comm.EnumHelper.EnumToHashtable(typeof(tImageFormat)); foreach (string item in arr.Values) cb.Items.Add(item);

其中的cb表示ComboBox对象,你可以替换成你的下拉框对象。