草庐IT

system-verilog

全部标签

c# - 将 System.Json 用于非 Silverlight 项目?

知道怎么做吗?如果不可能,什么是适用于C#的良好JSON库? 最佳答案 System.Json现在可通过NuGet在非Silverlight项目中使用(.Net的包管理系统)并有望作为vnext核心框架的一部分发布。NuGet包名为JsonValue.假设我们在字符串变量json中有以下JSON:[{"a":"foo","b":"bar"},{"a":"anotherfoo","b":"anotherbar"}]我们可以使用以下代码将值“anotherbar”写入控制台:usingSystem.Json;dynamicjsonObj

c# - 是否有 System.Text.StringBuilder 的二进制等价物?

我在C#中连接大量byte[]数组。如果我对字符串执行此操作,我会使用StringBuilder——是否有适用于byte[]数组中的二进制数据的等效类? 最佳答案 我不认为有一个完全等价的东西,但你可以用BinaryWriter来完成它:http://msdn2.microsoft.com/en-us/library/system.io.binarywriter.aspxMemoryStreamm=newMemoryStream();BinaryWriterwriter=newBinaryWriter(m);writer.Write

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# - 抛出 '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# - 等于 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上找到