我使用了以下几件:
int[] a = {1, 2, 3, 0, 5, 0};
int x = a.Select(b => b != 0).Count();
我正在拿到6,作为价值,我如何能够获得4,而不是6。
请允许我指导我。
我使用了以下几件:
int[] a = {1, 2, 3, 0, 5, 0};
int x = a.Select(b => b != 0).Count();
我正在拿到6,作为价值,我如何能够获得4,而不是6。
请允许我指导我。
int[] a = {1, 2, 3, 0, 5, 0};
int x = a.Where(b => b != 0).Count();
其他人建议使用<条码>(条码>,后加<条码>,但你可以做更简单的事情:
int x = a.Count(b => b != 0);
http://msdn.microsoft.com/en-us/library/bb535181.aspx>overload of Count
采取先导,基本上只算出与上游相匹配的来源序列的要素。
正如其他人指出的那样,它之所以为<代码>Select做t 工作,是因为只有projects——它就是t filter<>。 http://www.un.org。
// Works but is horrible...
int x = a.Select(b => b != 0).Count(z => z);
页: 1 页: 1
请注意,其中任何一项都不做您的<>/>。 会谈结果见 积极<> > /m> 价值。 为此,请:
int x = a.Count(b => b > 0);
使用<条码>。
int x = a.Where(b => b != 0).Count();
2. 改变这一方向
int[] a = {1, 2, 3, 0, 5, 0};
int x = a.Select(b => b != 0).Count();
纽约总部
int[] a = {1, 2, 3, 0, 5, 0};
int x = a.Where(b => b != 0).Count();
不同之处
www.un.org/Depts/DGACM/index_spanish.htm 页: 1
发现物品与这些物品相匹配,只回报这些物品。
-> IEnumerable<A>
in, IEnumerable<A>
out
<>Select
来源中
- 设计;
你的法典只是将收集工作投向ool,如果其价值不是零,那么,如果是假的,则在档案用户的所在地,你就会真心。
e.g.
int[] a = {1, 2, 3, 0, 5, 0};
int x = a.Where(b => b != 0).Count();
您的错误是,{1, 2, 3, 0, 5, 0}.Select(b => b!= 0)
只是{true, real,不实,不实}
,这又是6个项目。 你可以更好地与<代码>保持一致。 如果是,那将给你过滤的序列:{1, 2, 3, 5}
。 由此而产生的顺序可适用<条码>。
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. ...