System.Array的。不包含&QUOT的定义;了ToList" [英] System.Array. does not contain a definition for "ToList"

查看:1591
本文介绍了System.Array的。不包含&QUOT的定义;了ToList"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到上述错误的了ToList()行的code以下

I'm getting the above error on the ToList() line of the code below

if (emailReplyTo != null)
{
  System.Collections.Generic.List<String> replyto
    = emailReplyTo
    // Strip uneccessary spaces
    .Replace(", ", ",")
    .Split(',')
    .ToList();

  request.WithReplyToAddresses(emailReplyTo);
}

我已经包括 System.Collections中使用; 我的文件的顶部。 目标框架是3.5,所以这是为什么造成错误?

I have included using System.Collections; at the top of my file. The target framework is 3.5, so why is this causing an error?

推荐答案

了ToList 你正在寻找的方法是一个扩展方法。尝试添加该使用指令文件的顶部:

using System.Linq;

通过添加此使用指令你指示,在该命名空间的任何扩展方法应该导入的编译器。这是怎样的一个耻辱,有从Visual Studio没有更多的帮助身边导入扩展方法(ReSharper的做到这一点相当不错)。

By adding this using directive you are indicating to the compiler that any extension methods in that namespace should be imported. It's kind of a shame that there isn't more help from Visual Studio around importing extension methods (ReSharper does this rather nicely).

这篇关于System.Array的。不包含&QUOT的定义;了ToList&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆