我需要帮助发表以下声明,以便改写明我如何这样做?
for (int row = 0; row < rows; row++)
{
for (int column = 0; column < columns; column++)
{
gList.Add(new G(this, new L(row, column), 0, 20, 30));
}
}
thanks for all the help!!!
我需要帮助发表以下声明,以便改写明我如何这样做?
for (int row = 0; row < rows; row++)
{
for (int column = 0; column < columns; column++)
{
gList.Add(new G(this, new L(row, column), 0, 20, 30));
}
}
thanks for all the help!!!
List<G> gList = Enumerable.Range(0, rows)
.SelectMany(row => Enumerable.Range(0, columns)
.Select(col => new G(this, new L(row, col), 0, 20, 30)))
.ToList();
var gList = Enumerable.Range(0, rows)
.SelectMany(row =>
Enumerable.Range(0, columns)
.Select(column => new G(this, new L(row, column), 0, 20, 30)
)
).ToList() or .ToArray();
选择管理将把从选中返回的“数字”制成“数字”。
var gList = from row in Enumerable.Range(0, rows)
from col in Enumerable.Range(0, columns)
select new G(this, new L(row, col), 0, 20, 30)
我赞成像这样有线性 car客。
Give me the indexes, Project each Index to a new L
, Project each L
to a new G
,并将由此产生的物体顺序排列在一份名为g的清单上。 名单/编号。
var indexes = from row in Enumerable.Range(0, rows)
from column in Enumerable.Range(0, columns)
select new { Row = row, Column = column };
var ls = indexes.Select(index => new L(index.Row, index.Column));
var gs = ls.Select(l => new G(this, l, 0, 20, 30)).ToList();
var gList = gs.ToList();
注: 名单代码>是您希望补充的现有清单,可以替换最后一行。
gList.AddRange(gs);
它完全像它所做的那样。
如你从其他答复中看到的那样,使用拉姆布达斯不一定会导致更清洁的法典。 除非你有具体理由在此案中使用拉姆布达斯,否则我会像现在这样离开。
可读性应当成为你的首要关切,但我想使用一个正常的<条码>。 休息可能稍快一些,因为你没有工作电话的间接费用,但大多数情况下的差不多就赢得了。
把一切都变成一个单一的表达方式,会导致可怕的法典。 为什么你们会这样做? 是否提供了以下帮助:
public IEnumerable<L> GenerateLs(int rows, int columns)
{
for (int row = 0; row < rows; row++)
{
for (int column = 0; column < columns; column++)
{
yield return new L(row, column);
}
}
}
gList.Add(l => GenerateLs(rows,columns).Select(new G(this,l,0,20,30)));
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
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. ...
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 ...
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 ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
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, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
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. ...