正则表达式Regex.Match抛出argumentnullexception错误.input值不能为空...
foreach (DictionaryEntry ide in this.urlAndLinks)
{
foreach (DictionaryEntry idUr in this.keyWordHash)
{
if ((string)ide.Value != "" && (string)ide.Key != "")
{
string keyWord = (string)idUr.Key;
string filter = "\\D*" + keyWord + "\\D*";
Regex reg = new Regex(filter,RegexOptions.IgnoreCase);
string titleInIDE = (string)ide.Value;
try
{
Match match = reg.Match(titleInIDE);
}
catch (Exception ee)
{
throw (new ArgumentException(ee.Message));
}
查了下该方法,似乎不抛出错误啊?请大家教教!
问题点数:30、回复次数:5Top
1 楼love830315(因为笨,所以要比别人更努力)回复于 2005-04-03 23:25:12 得分 0
对CSDN失去信心呢!这几天问了几个问题,到现在为止还没有一个回答..连UP都只有很少的几个..
下面进来的朋友请推荐几个其他的论坛吧!!!-_-Top
2 楼leogigi()回复于 2005-04-03 23:38:16 得分 5
呵呵,我来顶一下吧,但实在是不愿意看代码,我一般都不看有代码的帖子的,而且也不会写代码回帖,没办法人的心理原因吧!~~~~~~Top
3 楼saucer(思归)回复于 2005-04-03 23:38:28 得分 25
make sure titleInIDE is not null
titleInIDE = (string)ide.Value;
Console.WriteLine(titleInIDE != null);
Top
4 楼love830315(因为笨,所以要比别人更努力)回复于 2005-04-04 00:00:49 得分 0
try
{
Match match = reg.Match(titleInIDE);
}
catch (Exception ee)
{
throw (new ArgumentException(ee.Message));
}
是包含在下面的if 语句里面的.
if ((string)ide.Value != "" && (string)ide.Key != "")
{
string titleInIDE = (string)ide.Value;
}
应该不存在titleInIDE == NULL的可能性啊??
因为是用作类库的.所以只能呆会测试了..汗!Top
5 楼love830315(因为笨,所以要比别人更努力)回复于 2005-04-04 00:17:06 得分 0
问题解决了.
if (ide.Value != null && ide.Key != null && ide.Value != "" && ide.Key != "")
可是我还是有个问题.如果ide.Value == null的话.ide.Value != ""为什么不会报错了?谢谢回答.Top




