LINQ运算符'=='不能应用于'char'和'string'类型的操作数

Tho*_*mas -8 c# linq

我过去几乎没用过LINQ.当我今天尝试使用LinqPad撰写一个小LINQ查询时,我收到以下错误:

Operator '==' cannot be applied to operands of type 'char' and 'string'

这是我试写的脚本:

void Main()
{
            var csvlines = File.ReadAllLines(@"M:\smdr(backup08-06-2015).csv");
            var csvLinesData = csvlines.Skip(1).Select(l => l.Split(',').ToArray());
            var csvData = csvLinesData.Where(l => (!l[12].Contains("VM") && l[12] != "Voice Mail")).ToArray();
            var user = (from r in csvData
                        orderby r[12]
                        select new User
                        {
                            CSRName = r[12],

                            Incomming = (from r1 in r
                                         where r1[4] == "I"
                                         select r1).Count(),
                            outgoing = (from r1 in r
                                        where r1[4] == "O"
                                        select r1).Count()



                        }).ToList();
                        user.Dump();
}

class User
{
    public string CSRName;
    public int Outgoing;
    public int Incomming;
    public int calltransfer;
}
Run Code Online (Sandbox Code Playgroud)

编辑1

根据建议,我编辑了代码

                    select new User 
                    {
                        CSRName=r[12],
                        Incomming=(from r1 in r
                                  where r1[4]=='I'
                                  select r1).Count(),
                        outgoing = (from r1 in r
                                    where r1[4] == 'O'
                                    select r1).Count()

                    }).ToList();
Run Code Online (Sandbox Code Playgroud)

现在它编译,但它抛出了一个不同的错误:

IndexOutOfRangeException: Index was outside the bounds of the array.

我在哪里弄错了?

fub*_*ubo 7

你正在比较字符串和字符类型

更换

where r1[4] == "I"/ where r1[4] == "O"

where r1[4] == 'I'/ where r1[4] == 'O'