本文介绍了“字符串"不包含"IsNullOrWhiteSpace"的定义如何解决此错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能知道.
它显示错误,如字符串"不包含"IsNullOrWhiteSpace"的定义如何解决此错误?
Can anyone know.
it show error like ,''string'' does not contain a definition for ''IsNullOrWhiteSpace'' how to solve this error?
public object SQLExecuteNonQuery(string procedureName, Hashtable cmdParms)
{
try
{
_SqlConnection = GetSQLConnection();
//Open SQL Connection
_SqlConnection.Open();
_SqlCommand = new SqlCommand(procedureName, _SqlConnection);
_SqlCommand.CommandType = CommandType.StoredProcedure;
//null or empty checking procdure name and hashtable
if (cmdParms.Count > 0 && !string.IsNullOrWhiteSpace(procedureName))
{
foreach (DictionaryEntry de in cmdParms)
{
//adding sql parameter
_SqlCommand.Parameters.Add(new SqlParameter(de.Key.ToString(), de.Value));
}
}
//Executing SQl Command
return _SqlCommand.ExecuteScalar();
}
推荐答案
public static class StringExtensions
{
public static bool IsNullOrWhiteSpace(string value)
{
if (value != null)
{
for (int i = 0; i < value.Length; i++)
{
if (!char.IsWhiteSpace(value[i]))
{
return false;
}
}
}
return true;
}
}
可以这样使用:
bool isNullOrWhiteSpace = StringExtensions.IsNullOrWhiteSpace("foo bar");
which could be used like this:
bool isNullOrWhiteSpace = StringExtensions.IsNullOrWhiteSpace("foo bar");
这篇关于“字符串"不包含"IsNullOrWhiteSpace"的定义如何解决此错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!