如何将Guid列表拆分为列表的一小部分

时间:2014-05-05 14:21:59

标签: c# linq nhibernate

我有一个guchar List类型的v​​archar(Max)。这个列表有很多跨越sql限制的Guid。我将这个列表分成小列表,如下所示。

 var sublists = customerList
               .Select((x, i) => new { Index = i, Value = x })
               .GroupBy(x => x.Index / 2000)
               .Select(x => x.Select(v => v.Value.ToString()).ToList())
               .ToArray();

但是这个列表以char格式显示,如下所示。

enter image description here

我不明白为什么这会以char格式出现。我犯了什么错误吗?

2 个答案:

答案 0 :(得分:1)

试试这个:

string[] sublists = customerList.Substring(0,2000).Split(',');
sublists = sublists.Take(sublists.Length - 1).ToArray();

这应该可以为您提供所需的结果。

答案 1 :(得分:1)

如果customerList是一个大字符串:

var sublists = customerList
    .Split(",")
    .Select((x, i) => new { Index = i, Value = x })
    .GroupBy(x => x.Index / 2000)
    .Select(x => x.Select(v => v.Value).ToList())
    .ToList();

here的解决方案相同,但您必须先添加Split方法。