我在下面的代码的ToList()行中收到上述错误
if (emailReplyTo != null)
{
System.Collections.Generic.List<String> replyto
= emailReplyTo
// Strip uneccessary spaces
.Replace(", ", ",")
.Split(',')
.ToList();
request.WithReplyToAddresses(emailReplyTo);
}
Run Code Online (Sandbox Code Playgroud)
我已将其包含using System.Collections;在我的文件顶部.目标框架是3.5,为什么这会导致错误?
多年来,我的数据库已经有了几个连续的维护者,并且可能已经存在的任何命名准则都被忽略了.
我想将存储过程重命名为一致的格式.显然,我可以在SQL Server Management Studio中重命名它们,但这不会更新后面的网站代码(C#/ ASP.NET)中的调用.
我能做些什么来确保所有调用都更新为新名称,而不是在代码中搜索每个旧的过程名称?Visual Studio是否具有重构此类存储过程名称的能力?
NB我不相信我的问题是这个问题的重复,因为后者仅仅是在数据库中重命名.
我在python脚本中有以下代码
try:
# send the query request
sf = urllib2.urlopen(search_query)
search_soup = BeautifulSoup.BeautifulStoneSoup(sf.read())
sf.close()
except Exception, err:
print("Couldn't get programme information.")
print(str(err))
return
Run Code Online (Sandbox Code Playgroud)
我很担心,因为如果我遇到错误sf.read(),那么sf.clsoe()就不会被调用.我尝试放入sf.close()一个finally块,但是如果有一个异常,urlopen()则没有文件要关闭,我在finally块中遇到异常!
所以我试过了
try:
with urllib2.urlopen(search_query) as sf:
search_soup = BeautifulSoup.BeautifulStoneSoup(sf.read())
except Exception, err:
print("Couldn't get programme information.")
print(str(err))
return
Run Code Online (Sandbox Code Playgroud)
但这会with...在行上引发无效的语法错误.我怎么能最好地处理这个问题,我觉得很蠢!
正如评论者指出的那样,我使用的是Pys60,它是python 2.5.4