关于 trim cTypeCode只做了声明,没有赋值。string cTypeCode = "";应该先赋值再使用 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 錯誤 1 使用未指定的區域變數 'cTypeCode' C:\Documents and Settings\bearcat\Local Settings\Application Data\Temporary Projects\csharp2005\Form1.cs 26 17 csharp2005cTypeCode 要賦值 if ((cTypeCode.Trim() == "") || cTypeCode == null) 而且,判断空字符串,更稳妥的方法是cTypeCode.Trim().Length==0 cTypeCode没有负值cTypeCode=string.empty;if(string.IsNullOrEmpty(cTypeCode)){ cSearchCode = "select * from Parameter"; }else{} string cTypeCode;//这里只是实例了,而没有实例化,所以cTypeCode为null cTypeCode="cTypeCode";//实例化 if(string.string.IsNullOrEmpty(cTypeCode)) { cSearchCode = "select * from Parameter"; } else { cSearchCode = "select * from Parameter where cBelong ='"+cTypeCode+"'"; } string cTypeCode;//这里只是实例了,而没有实例化,所以cTypeCode为null cTypeCode="cTypeCode";//实例化 if(string.IsNullOrEmpty(cTypeCode)) { cSearchCode = "select * from Parameter"; } else { cSearchCode = "select * from Parameter where cBelong ='"+cTypeCode+"'"; } 判断是否 null,很多人都会忘记,是在不知道就在定义时赋上值,我就是这样做的。 建议采用string.IsNullOrEmpty来进行字符串是否为空的判断 MDI父子窗口问题 C# 字符串比较问题 C#网络编程 如何让 ContextStripMenu 滚动?! 请教:如何向XML结构中插入数据? 关于用户自定义计算公式如何分析?? 求助C#字符串问题 打印网格程序开源了,请需要的朋友进来看看,不要让帖子沉下去了 C#打包找不到模块了。 急救!很郁闷的一个问题。不知道错在哪了!高手快来帮帮我 关于向listview 中添加数组的方法 e.state啥意思
cTypeCode 要賦值
{
cSearchCode = "select * from Parameter";
}
else
{
}
cTypeCode="cTypeCode";//实例化
if(string.string.IsNullOrEmpty(cTypeCode))
{
cSearchCode = "select * from Parameter";
}
else
{
cSearchCode = "select * from Parameter where cBelong ='"+cTypeCode+"'";
}
cTypeCode="cTypeCode";//实例化
if(string.IsNullOrEmpty(cTypeCode))
{
cSearchCode = "select * from Parameter";
}
else
{
cSearchCode = "select * from Parameter where cBelong ='"+cTypeCode+"'";
}