小编fea*_*urs的帖子

System.Array的.不包含"ToList"的定义

我在下面的代码的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,为什么这会导致错误?

.net-3.5 c#-3.0

34
推荐指数
5
解决办法
5万
查看次数

如何在不破坏内容的情况下重命名许多存储过程?

多年来,我的数据库已经有了几个连续的维护者,并且可能已经存在的任何命名准则都被忽略了.

我想将存储过程重命名为一致的格式.显然,我可以在SQL Server Management Studio中重命名它们,但这不会更新后面的网站代码(C#/ ASP.NET)中的调用.

我能做些什么来确保所有调用都更新为新名称,而不是在代码中搜索每个旧的过程名称?Visual Studio是否具有重构此类存储过程名称的能力?

NB我不相信我的问题是这个问题的重复,因为后者仅仅是在数据库中重命名.

sql-server stored-procedures renaming visual-studio

14
推荐指数
2
解决办法
1575
查看次数

用urllib2.urlopen()正确打开关闭文件

我在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

python exception-handling urllib2 pys60

7
推荐指数
3
解决办法
1万
查看次数