English 中文(简体)
我要检查一个数字可观但效率极低的国际数字。
原标题:I want to check the Count of an IEnumerable but it s very inefficient
最佳回答

当你把ToList(ToList)(一)称作“我”时,你正在做的是计算数字清单的所有内容,并将结果放在一个集装箱内。 因此,“密码星号”是把ToList(ToList)称作同一数字E的多次编码,只应当一劳永逸地加以保存。

有一种简单的umb。 如果你在计算整个清单(Linq表述)上操作,或者简单地从开始到完成清单,那么如果你需要以指数方式查阅清单,或根据清单计算元素数或对两个指示进行核对,就首先制作一个清单并加以使用。

i.e.

List<Friend> friends = FindFriends().ToList();
//Then use the friends list....

现在,关于你们名单上是否有任何东西,正如这里的夫妇一样,你可以使用具有约束力的数据,并像项目Control一样加以控制,但如果你真想建立国际倡议,那么就能够积极利用一种循环,不把指数化成阵列。

List<Friend> friends = FindFriends().ToList();
if(friends.Count > 0)
{
  foreach(Friend f in friends)
  {
    //Create your Control(s) and add them to your form or panel s controls container
    // somthing like (untested) myPanel.Controls.Add(new Label(){Text = f.Name});
  }
}
问题回答

(1) 将朋友名单并入<代码>ListBox。 你们可以利用数据模板展示图像和标签。

(2) 电话:Any()。

在本案中,如果发言之前,仅打电话ToList(),而不是每次制作名单。

EDIT

您不妨研究MVVER系统模式,并使XAML对数据进行控制。





相关问题
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. ...

热门标签