草庐IT

system-dependent

全部标签

c# - : List<T>. Add() 或 System.Array.Resize() 哪个更有效?

我正在尝试确定何时使用List.Add()更有效与使用Array.Resize()相比方法。Array.Resize的文档说它复制了整个数组,并将其放入一个新对象中。旧对象将不得不被丢弃。这个旧对象在哪里?在栈上还是堆上?我不知道List.Add()是如何工作的。有谁知道List.Add方法与静态Array.Resize方法相比如何?我对内存使用(和清理)以及300种值类型和20,000种值类型哪个更好。就其值(value)而言,我计划在.NET的一种嵌入式版本上运行此代码。可能是.NETGadgeteer 最佳答案 你应该使用Li

c# - 如何创建从 System.Drawing.Bitmap 对象开始的 iTextSharp.text.Image 对象?

我是iTextSharp(iText的C#版本)的新手:我有这样的东西:System.Drawing.Bitmapbitmap=(System.Drawing.Bitmap)ChartHelper.GetPdfChart((int)currentVuln.UrgencyRating*10);iTextSharp.text.Imageimg=iTextSharp.text.Image.GetInstance(bitmap);vulnerabilityDetailsTable.AddCell(newPdfPCell(img){Border=PdfPCell.RIGHT_BORDER,Bor

c# - 为什么 System.Array 类实现 IList 但不提供 Add()

这段代码:int[]myArr={1,2};myArr.Add(3);在构建时抛出以下错误:errorCS1061:'System.Array'doesnotcontainadefinitionfor'Add'andnoextensionmethod'Add'acceptingafirstargumentoftype'System.Array'couldbefound(areyoumissingausingdirectiveoranassemblyreference?)IList接口(interface)有Add()方法,为什么Array没有实现?更新:我从答案中看到它确实明确地实现了

c# - System.Windows.Input 不存在?

我的程序顶部有usingSystem.Windows.Input;,但它给我一个错误提示:Thetypeornamespacename'Input'doesnotexistinthenamespace'System.Windows'(areyoumissinganassemblyreference?)当我在Windows之后的句点上让IntelliSense弹出时,它只将Forms列为有效选项。我在VisualC#2010Express中使用.NETFramework4.0...我该如何解决这个问题? 最佳答案 我怀疑您创建的是Wi

c# - 未知模块中发生类型为 'System.IO.FileNotFoundException' 的未处理异常

我正在开发一个C#应用程序,但在调试运行时出现以下错误:Anunhandledexceptionoftype'System.IO.FileNotFoundException'occurredinUnknownModule.Additionalinformation:Couldnotloadfileorassembly'Autodesk.Navisworks.Timeliner.dll'oroneofitsdependencies.Thespecifiedmodulecouldnotbefound.Autodesk.Navisworks.Timeliner.dll位于应用程序的调试文件夹

c# - 简易喷油器 : Factory classes that need to create classes with dependencies

我有一个工厂类,它创建了几个不同类型的类。工厂在容器中注册。鉴于它们也具有依赖性,在工厂内部创建类的推荐方法是什么。我显然想避免对容器的依赖,但如果我新建这些类,那么它们将不会使用容器。例如publicclassMyFactory{publicIMyWorkerCreateInstance(WorkerTypeworkerType){if(workerType==WorkerType.A)returnnewWorkerA(dependency1,dependency2);returnnewWorkerB(dependency1);}}所以问题是我从哪里获得这些依赖项。一种选择是使它们成

c# - 抛出 'System.StackOverflowException' 类型的异常

我的程序抛出这个异常:System.StackOverflowException当编译器执行设置属性时。wine类:classwine{publicintyear;publicstringname;publicstaticintno=5;publicwine(intx,stringy){year=x;name=y;no++;}publicintprice{get{returnno*5;}set{price=value;}}}程序类:classProgram{staticvoidMain(string[]args){winew1=newwine(1820,"JackDaniels");C

c# - Visual Studio 2010 : dependency graph

我有VS2010专业版。我能做些什么来使用“依赖图”。我没有“建筑”版。有没有我可以使用的免费插件。如果没有,是否有任何免费的第3方工具可以帮助我做同样的事情。谢谢 最佳答案 我需要类似的东西,但不想为此付费(或安装)工具。我createdaquickPowerShellscriptthatgoesthroughtheprojectreferences并将它们吐出yuml.me改为友好格式:FunctionGet-ProjectReferences($rootFolder){$projectFiles=Get-ChildItem$r

c# - 等于 System.Collections.Generic.List<T>... 的方法?

我正在创建一个派生自List的类...publicclassMyList:List{}我已经覆盖了MyListItem的Equals...publicoverrideboolEquals(objectobj){MyListItemli=objasMyListItem;return(ID==li.ID);//IDisapropertyofMyListItem}我也想在MyList对象中有一个Equals方法,它将比较列表中的每个项目,在每个MyListItem对象上调用Equals()。简单地调用...会很好MyListl1=newMyList(){newMyListItem(1),ne

c# - 在 System.IO.Directory.GetFiles() 中排除文件扩展名

有没有办法获取文件夹中的文件数,但我想排除扩展名为jpg的文件?Directory.GetFiles("c:\\Temp\\").Count(); 最佳答案 试试这个:varcount=System.IO.Directory.GetFiles(@"c:\\Temp\\").Count(p=>Path.GetExtension(p)!=".jpg");祝你好运! 关于c#-在System.IO.Directory.GetFiles()中排除文件扩展名,我们在StackOverflow上找到