草庐IT

list-type

全部标签

c# - List<T> 是链表吗?

是System.Collections.Generic.List一种linkedlist(不是LinkedList类)?Alinkedlistisadatastructureconsistingofagroupofnodeswhichtogetherrepresentasequence.Underthesimplestform,eachnodeiscomposedofadatumandareference(inotherwords,alink)tothenextnodeinthesequence.Alinkedlistwhosenodescontaintwofields:aninteg

C# 范式 : Side effects on Lists

我正在努力加深对副作用以及应如何控制和应用它们的理解。在下面的航类列表中,我想为每个满足条件的航类设置一个属性:IEnumerablefResults=getResultsFromProvider();//Setallnon-stopflightsdescriptionfResults.Where(flight=>flight.NonStop).Select(flight=>flight.Description="FlyDirect!");在这个表达式中,我对我的列表有副作用。根据我有限的知识,我知道前。“LINQ仅用于查询”和“列表只有少数操作,分配或设置值不是其中之一”和“列表应该

c# - 如何将 XML 文件读入 List<>?

我有一个List我将其写入XML文件。现在我正在尝试读取同一个文件并将其写回List.有没有办法做到这一点? 最佳答案 我认为最简单的方法是使用XmlSerializer:XmlSerializerserializer=newXmlSerializer(typeof(List));using(FileStreamstream=File.OpenWrite("filename")){Listlist=newList();serializer.Serialize(stream,list);}using(FileStreamstream=

c# - 错误 : Cannot find all types required by the 'async' modifier. 您是否针对错误的框架版本,或缺少对程序集的引用?

我的电脑配置如下:Windows8VisualStudio2012.NETFramework4.5我的项目配置是:WP7.1银光4.0.NETFramework4.0CTPASYNC(已安装,使用async和await关键字)该项目是使用VS2010在Windows7机器上为WP7.1编写的。现在我已经将PC升级到Windows8并安装了VS2012。然而,该项目提示“async”修饰符。无法找到“async”修饰符所需的所有类型。您是针对错误的框架版本,还是缺少对程序集的引用?知道如何解决这个问题吗?谢谢! 最佳答案 有支持Sil

c# - .NET List.sort() 的时间复杂度是多少

C#的List.Sort()的时间复杂度是多少?我猜是o(N)但是我找了很多,都没有得到准确的结果。 最佳答案 http://msdn.microsoft.com/en-us/library/b0zbh7b6.aspxThismethodusesArray.Sort,whichusestheQuickSortalgorithm.Thisimplementationperformsanunstablesort;thatis,iftwoelementsareequal,theirordermightnotbepreserved.Inco

c# - 如何将 System.Linq.Enumerable.WhereListIterator<int> 转换为 List<int>?

在下面的示例中,我如何轻松转换eventScores至List这样我就可以将它用作prettyPrint的参数?Console.WriteLine("ExampleofLINQ'sWhere:");Listscores=newList{1,2,3,4,5,6,7,8};varevenScores=scores.Where(i=>i%2==0);Action,string>prettyPrint=(list,title)=>{Console.WriteLine("***{0}***",title);list.ForEach(i=>Console.WriteLine(i));};score

c# - list<T> 字段的平均计数

我有A的列表,我想计算它的字段a的平均值。最好的方法是什么?classA{inta;intb;}voidf(){varL=newList();for(inti=0;i 最佳答案 Enumerable.Average有一个需要Func的重载作为论点。usingSystem.Linq;list.Average(item=>item.a); 关于c#-list字段的平均计数,我们在StackOverflow上找到一个类似的问题: https://stackoverf

c# - 继承 List<T> 来实现集合是个坏主意吗?

我曾经读过ImaarSpaanjars的一篇关于如何构建3层应用程序的文章。(http://imar.spaanjaars.com/416/building-layered-web-applications-with-microsoft-aspnet-20-part-1)这已经成为我编码的基础了一段时间。因此我像他一样通过继承List来实现集合.因此,如果我有一个名为Employee的类,为了实现一个集合,我还将有一个Employees类,如下所示。classEmployee{intEmpID{get;set;}stringEmpName{get;set;}}classEmployee

c# - Visual Studio : Automatically insert a space after typing if(

我们有一个代码风格检查器,它在每次checkin之前运行,要求C#if语句的格式如下:if(condition)但是,我的肌肉内存力已经可以打字了:if(condition)有什么方法可以让VisualStudio2010在我键入没有空格的情况下自动插入该空格?我知道你可以设置它,当你粘贴代码时,它会自动执行此操作,但不会在键入时自动执行。谢谢! 最佳答案 工具>选项>文本编辑器>C#>格式化>间距然后选中/勾选Insertspaceafterkeywordsincontrolflowstatements,它列在Setothersp

c# - 如何调整 "is a type but is used like a variable"?

我正在尝试在网络服务中生成一些代码。但它返回了2个错误:1)List是一种类型,但像变量一样使用2)方法“Customer”没有重载接受“3个参数”[WebService(Namespace="http://tempuri.org/")][WebServiceBinding(ConformsTo=WsiProfiles.BasicProfile1_1)][ToolboxItem(false)]publicclasswstest:System.Web.Services.WebService{[WebMethod]publicListGetList(){Listli=List();li.A