English 中文(简体)
不能将真空划给一种隐含的当地变量
原标题:Cannot assign void to an implicitly-typed local variable
var query = rep.GetIp()  // in this line i have the error
           .Where(x => x.CITY == CITY)
           .GroupBy(y => o.Fam)
           .Select(z => new IpDTO
                        {
                            IId = z.Key.Id,
                            IP = z.Select(x => x.IP).Distinct()
                        })
           .ToList().ForEach(IpObj => IpObj.IP.ToList().ForEach(ip => PAINTIP(ip)));

在我管理该法典时,我有错误:

不能将真空划给一种隐含的当地变量

I googled and found that it is a type issue because foreach is not a LINQ function? I cannot understand where the void is!

最佳回答
  • <代码>Select( ReturnIE amountable<T>,ToList( ReturnList<T>

so:

List<X> x = ...Select(x => x).ToList(); // List<T>

x.F或Each(x => x); // void

由于您可以指定<代码> 撤销至,List<T>


var query = rep.GetIp()  // in this line i have the err或
           .Where(x => x.CITY == CITY)
           .GroupBy(y => o.Fam)
           .Select(z => new IpDTO
                        {
                            IId = z.Key.Id,
                            IP = z.Select(x => x.IP).Distinct()
                        });

f或each (var dto in query)
{
    f或each (var ip in dto.IP)
    {
        PAINTIP(ip);
    }
}

var query = ....
           .SelectMany(z => z.Select(x => x.IP).Distinct());

f或each (var ip in query)
{
    PAINTIP(ip);
}
问题回答

<>ForEach(>>>不退还任何款项。 其类型无效。

http://msdn.microsoft.com/en-us/library/bwabdf9z.aspx”

I saw your other questions, wherein you have asked similar question for the same query. The code partially looks like this :

var Q = rep.GetIp()
        .Where(x => x.CITY == CITY)
        .GroupBy(y => o.Fam)
        .Select(z => new IpDTO
        {
          IId = z.Key.Id,
          IP = z.Select(x => x.IP).Distinct()
       });

Looks like you have used the answer as such and you are trying to assign the returned value from the query to the variable "Q". Check out your previous post : syntax in LINQ IEnumerable<string>

正如其他人所说的那样,每个回归类型都是“避免”。 一旦“Q”变量开始收集,你应称“ForEach”。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签