草庐IT

3gp-how-convert

全部标签

C#,正则表达式 : how to parse comma-separated values,,其中一些值可能是引号本身包含逗号的字符串

在C#中,使用Regex类,如何解析以逗号分隔的值,其中一些值可能是引号本身包含逗号的字符串?usingSystem;usingSystem.Text.RegularExpressions;classExample{publicstaticvoidMain(){stringmyString="cat,dog,\"0=OFF,1=ON\",lion,tiger,'R=red,G=green,B=blue',bear";Console.WriteLine("\nmyStringis...\n\t"+myString+"\n");Regexregex=newRegex("(?输出(部分)如下

c# - Visual Studio /ReSharper : How to wrap long lines with commas before params?

我一直在使用ReSharper自定义我的格式设置以进行代码清理。到目前为止,我已经能够使清理规则与我的编码风格相匹配:ReSharper->选项->语言->C#->格式样式有一件事我还没有弄清楚如何做,那就是如何让参数/字段/列表项用前导逗号而不是尾随逗号包裹。我想要的例子:varlist=newList{"apple","banana","orange"};我目前得到的例子:varlist=newList{"apple","banana","orange"}; 最佳答案 (不是答案,但这不适合发表评论。)有些人喜欢前导逗号而不是尾

c# - 在 winforms 应用程序中缓存 GDI+ 对象 : is it worth it and how to do it right?

对于我的一些winforms应用程序,我需要创建一大堆GDI+对象(画笔、笔、字体等)并一遍又一遍地使用它们。我创建了一个ghetto缓存单例来完成我需要的,但是代码味道太重了......publicsealedclassGraphicsPalette{publicstaticreadonlyGraphicsPaletteInstance=newGraphicsPalette();staticGraphicsPalette(){}privateDictionarysolidBrushes;//multithreadingprivateobjectbrushLock;privateGra

c# - 高级 : How to optimize my complex O(n²) algorithm

我有以下人员和地点数据:Person实体有IList每个都有IList可能的地方Schedule即日模式。10天可用4天不可用在特定的DateRangePlaces内日期范围必须遵守Schedule人是否可以去特定地方的模式。Place实体有IList每个定义每个日期范围内的开始/结束时间重叠的日期范围作为LIFO。因此,对于之前已经定义的每一天,新的时间定义优先。问题现在我需要做这样的事情(用伪代码):foreachPlace{foreachDaybetweenminimumandmaximumdateinIList{getasetofPeopleapplicableforPlace

c# - (-) Convert 方法中使用的符号

我在浏览一些C#代码时发现了这一行:Matrix[i,j]=Convert.ToInt32(grab[i,j]-'0');(-)到底是做什么的?如果有的话,还有另一种写法吗? 最佳答案 -(减号)做的正是它一直做的事——减法。这里发生的事情是从[i,j]处的字符中减去零'0'的字符代码。这会将数字字符转换为相应数字的整数值。例如,如果你计算chardigitChar='7';intdigitVal=digitChar-'0';digitVal的值为七。 关于c#-(-)Convert方法

c# - UWP : How to resize an Image

我有一个JPEG图像存储在我想要调整大小的Byte[]中。这是我的代码:publicasyncTaskResizeImage(byte[]imageData,intreqWidth,intreqHeight,intquality){varmemStream=newMemoryStream(imageData);IRandomAccessStreamimageStream=memStream.AsRandomAccessStream();vardecoder=awaitBitmapDecoder.CreateAsync(imageStream);if(decoder.PixelHeigh

c# - 城堡动态代理 : How to Proxy Equals when proxying an interface?

我需要使用CaSTLeDynamicProxy来代理接口(interface),方法是向ProxyGenerator.CreateInterfaceProxyWithTarget提供接口(interface)实例。我还需要确保对Equals、GetHashCode和ToString的调用命中了我正在传递的具体实例上的方法,但我无法让它工作。换句话说,我希望这个小示例打印两次True,而实际上它打印True,False:usingSystem;usingCastle.Core.Interceptor;usingCastle.DynamicProxy;publicinterfaceIDum

c# - ListBox Groupstyle 显示 : How to design a group name?

我想在列表框中按创建日期对我的项目(图像)进行分组。然后我只使用这段代码:但是当我尝试应用某些样式(即边框)时,我没有显示任何组名。只有边框这是我使用DateTime进行分组的新实现:这是我主窗口中的ICollectionView:ICollectionViewview=CollectionViewSource.GetDefaultView(CollectedFiles);view.GroupDescriptions.Add(newPropertyGroupDescription("DateCreated",newDateTimeToDateConverter()));view.Sor

c# - 通过 ref : cannot convert from 'Foo' to 'ref IFoo' 传递实现

这个问题在这里已经有了答案:Whydoesn't'ref'and'out'supportpolymorphism?(10个答案)关闭3年前。有人可以向我解释为什么这在C#中是不正确的吗:namespaceNamespaceA{publicclassClassA{publicinterfaceIInterfaceA{StringProperty{set;}}}}namespaceNamespaceB{publicclassClassB{publicclassImpA:NamespaceA.ClassA.IInterfaceA{privateStringmProperty;publicSt

c# - .Net 4 : How to reference a dynamic object with property named "return"

我正在从公共(public)api检索json并使用JsonFx将其转换为动态对象。JsonFx.Json.JsonReaderreader=newJsonFx.Json.JsonReader();dynamicresponse=reader.Read(jsonAsString);json包含一个名为return的属性。例如{"result":"success","return":{"high":{"value":"3.85001","value_int":"385001","display":"3.85001\u00a0\u20ac","currency":"EUR"}}JsonFx