草庐IT

request-object

全部标签

c# - 我可以遍历 Collection.Request.Form 吗?

我有一些具有唯一ID的复选框。是否可以在一个表单集合中找到所有的checkbox+uniquenum?有点像-foreach(variteminCollection.Request.Form["checkbox"+withUniqueIDNum]){//code} 最佳答案 没有。相反,您可以遍历所有键,并检查它们是否以checkbox开头。例如:foreach(stringkeyinRequest.Form){if(!key.StartsWith("checkbox"))continue;...}NameValueCollecti

c# - DataContractJsonSerializer - 反序列化 List<object> 中的 DateTime

我在使用System.Runtime.Serialization.Json.DataContractJsonSerializer时遇到问题反序列化List中包含的DateTime实例的类.我似乎无法让DateTime反序列化回原始类型。DataContractJsonSerializer始终将其反序列化为格式为"/Date(1329159196126-0500)/"的字符串类型.如果我使用强类型List运行它,它会很好地序列化和反序列化。,但是我正在寻找方法让序列化器在遇到object的简单列表或数组时识别并正确反序列化DateTimes.请注意,DateTimes是此列表将永远包含的

c# - Azure 存储 : 403 Server failed to authenticate the request

我在此处和Google中进行了搜索,但找不到解决方案。我想使用我的C#代码从Azure存储Blob中读取文件。代码(仅6行)在另一个项目(Windows8.1通用应用程序)中运行良好,但在我的新Windows10UWP应用程序中运行不佳。这是我的代码:CloudStorageAccountstorageAccount=CloudStorageAccount.Parse(azureConnectionString);CloudBlobClientblobClient=storageAccount.CreateCloudBlobClient();CloudBlobContainercont

c# - IsKeyboardFocusable 在 Inspect Object 中为 true 但在我的应用程序中始终为 false

我正在学习UIAutomation,我发现我的“InspectObject”克隆显示IsKeyboardFocusable始终为false,即使它是true,所有其他信息都是相同的(正如您从图片)。有谁知道为什么我在检索值时将此属性视为false? 最佳答案 在InspectObject应用程序中,最新版本的WindowsAutomationCOMAPI(3.0)用于显示所有这些属性。但是默认的.NETUIAutomation实现并不基于WindowsAutomationAPI3.0COM接口(interface)(它基于此COMA

c# - Large Object Heap Compaction,什么时候好?

首先,多大才算大?有没有办法确定一个对象在堆中有多大?.Net4.5.1带有此LargeObjectHeapCompactionMode:AftertheLargeObjectHeapCompactionModepropertyissettoGCLargeObjectHeapCompactionMode.CompactOnce,thenextfullblockinggarbagecollection(andcompactionoftheLOH)occursatanindeterminatefuturetime.YoucancompacttheLOHimmediatelybyusingc

c# - WCF 调用在 Fiddler On 时工作,否则在调试时给出 400 Bad Request

未解决-仍在寻找解决方案。我正在进行WCF调用并传递SAMLtoken:UsingSAMLtokenwithWebService(wsdl)privatestaticstringserviceEndpoint="httpsserviceendpoint";publicstaticvoidCallProviderService(SecurityTokentoken){varbinding=newWS2007FederationHttpBinding(WSFederationHttpSecurityMode.TransportWithMessageCredential);binding.S

c# - 如何使用 Moq 为接口(interface)模拟 `object.Equals(object obj)`

我有一个有趣的问题要解决。考虑像这样的一些接口(interface):publicinterfaceIMyThing{intId{get;}}现在我想测试使用这个接口(interface)的代码。也许有一些LINQ魔法。像这样:publicclassSomeClass{privateIMyThing_thing;...publicboolHasThing(IEnumerablethings){returnthings.Contains(_thing);}}我正在模拟所有实现IMyThing的对象使用Moq:publicstaticIMyThingMockMyThing(intnewId

c# - Linq 和相等运算符 : Expression of type 'System.Int32' cannot be used for parameter of type 'System.Object'

我试图重写C#中的相等(==)运算符来处理任何类型与自定义类型的比较(自定义类型实际上是null周围的包装器/框)。所以我有这个:internalsealedclassNothing{publicoverrideboolEquals(objectobj){if(obj==null||objisNothing)returntrue;elsereturnfalse;}publicstaticbooloperator==(objectx,Nothingy){if((x==null||xisNothing)&&(y==null||yisNothing))returntrue;returnfal

c# - 运行所选代码生成器时出错 : 'Object reference not set to an instance of an object.' Error?

我已经尝试了所有解决方案,例如修复VS2013,但没有用。当您通过右键单击Controller文件夹创建Controller并添加Controller时,然后右键单击新创建的Controller的操作并选择添加View,当我尝试创建View时,它就发生了。这不是新项目,而是现有项目。 最佳答案 我在我的VS2017上遇到了这个问题,我通过这样做解决了它:转到C:\Users\username\AppData\Local\Microsoft\VisualStudio\15.0_7fca0c70,您将看到一个名为ComponentMod

C# System.Object.operator==()

我正在努力了解System.Object.operator==()的使用。我的EffectiveC#书和这里的页面(http://www.srtsolutions.com/just-what-is-the-default-equals-behavior-in-c-how-does-it-relate-to-gethashcode)说:“System.Object.operator==()将调用a.Equals(b)以确定a和b是否相等”。所以我的代码:objecta=1;objectb=1;if(object.Equals(a,b)){//Willgetherebecauseitcal