c#能不能定义string类型的枚举变量? 如题!如果不能该怎么做呢? string STDT_READ_MSG = "02";//学生卡读取留言 string CALL_BILLING = "03";//通话话单 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以用readonlypublic readonly string STDT_READ_MSG = "02";//学生卡读取留言public readonly string CALL_BILLING = "03";//通话话单 能不能用一个struct呀不知所云 public static class/* struct */ Strings{ public const string Value = "aa";} 枚举值只能是数字,但ToString()可以是字符串。 struct是结构体不是枚举哦.定义枚举可以用字符串啊.但他本来的值却是数字 楼主想把一些常量做成强类型吧?比如下面的: public struct CustomDefine { public static readonly string hahaTest = "hahaTest"; public struct CustomComm { public static readonly string NewLine = System.Environment.NewLine; public static readonly string Dot = "."; } public struct URLConst { public static readonly string HttpPrefx= "http"; public static readonly string HttpsPrefx = "https"; } } 引用时只要 //取haha string haha = CustomDefine.hahaTest; //结构中包含结构NewLine string hahaNewLine= CustomDefine.CustomComm.NewLine; 枚举是值类型、string是引用类型,类型之间可以互相转换,但是用string定义枚举不行吧! wpf 使用ObservableCollection 时 掉用多线程(下载)时 关于C# 未知数据类型的一个问题 请教一个SQL 复选框 有意思,在系统分区创建Program.cs居然神秘消逝 ★求助★如何固定用户控件的尺寸? 请问数据库里面的primary key的一个操作问题 silverlight DataField Grid 中的SLTextBox自动自增编号 如何让DataGrid控件的某一列不可输入,即变为只读,如何让其某一列的值只可输入数字(非常感谢!!!) 做一个信息管理系统,有几个疑问,忘各位兄弟赐教! 保存图像的问题 socket接收不同步,大侠请进啊!
public readonly string STDT_READ_MSG = "02";//学生卡读取留言
public readonly string CALL_BILLING = "03";//通话话单
public const string Value = "aa";}
struct是结构体不是枚举哦.定义枚举可以用字符串啊.但他本来的值却是数字
{
public static readonly string hahaTest = "hahaTest"; public struct CustomComm
{
public static readonly string NewLine = System.Environment.NewLine; public static readonly string Dot = ".";
} public struct URLConst
{
public static readonly string HttpPrefx= "http"; public static readonly string HttpsPrefx = "https";
}
}
只要
//取haha
string haha = CustomDefine.hahaTest;
//结构中包含结构NewLine
string hahaNewLine= CustomDefine.CustomComm.NewLine;
但是用string定义枚举不行吧!