草庐IT

method_idx

全部标签

c# - Resharper 中的警告 "Return value of pure method is not used"

我有一个快速的问题,关于我正在工作的c#项目中从VisualStudio中的Resharper收到的警告。警告是:"ReturnValueofpuremethodisnotused"发生这种情况的方法如下:privatestaticboolFilePathHasInvalidChars(stringuserInputPath){try{//thisiswherethewarningoccurs:Path.GetFullPath(userInputPath);}catch(Exceptione){Log.Error(String.Format("TheProgramfailedtorun

c# - 多线程,Task.Run 错误 'The call is ambiguous between the following methods or properties'

当我尝试构建项目时,显示以下错误消息。Thecallisambiguousbetweenthefollowingmethodsorproperties:'System.Threading.Tasks.Task.Run(System.Action)'and'System.Threading.Tasks.Task.Run(System.Func)'我该如何解决这个问题?publicstaticclassMaintananceManager{privatestaticThreadSafeSocialMediaListPostList=newThreadSafeSocialMediaList(

c# - 如何初始化 ConcurrentDictionary?错误 : "Cannot access private method ' Add' here"

我有一个静态类,我在其中使用字典作为查找表以在.NET类型和SQL类型之间进行映射。这是一个这样的字典的例子:privatestaticreadonlyDictionarySqlServerMap=newDictionary{{typeof(Boolean),"bit"},{typeof(Byte[]),"varbinary(max)"},{typeof(Double),"float"},{typeof(Byte),"tinyint"},{typeof(Int16),"smallint"},{typeof(Int32),"int"},{typeof(Int64),"bigint"},{

c# - IDX10603 : The algorithm: 'HS256' requires the SecurityKey. KeySize 大于 '128' 位。 KeySize 报告 : '32' . 参数名称 : key. KeySize

我刚刚使用Asp.NetCoreWebAPI并实现身份验证。我从Angular应用程序调用这个API。但我总是收到如下错误。IDX10603:Thealgorithm:'HS256'requirestheSecurityKey.KeySizetobegreaterthan'128'bits.KeySizereported:'32'.Parametername:key.KeySize下面是我在Startup.cs文件中的ConfigureServices代码。publicIServiceProviderConfigureServices(IServiceCollectionservice

c# - Visual Studio Community 2015 调试器在带有 "Evaluation of native methods is not supported"的条件断点处结束 - 如何修复?

我有一个条件断点,条件检查字符串的值,如果为真则停止。它停止了,但随后打开一个窗口说:断点的条件无法执行...返回的错误是“评估方法System.Collections.Specialized.NameValueCollection.get_Item()调用native方法”System.Globalization.TextInfo.Internal.GetCaseInsHash().不支持在此上下文中评估native方法。'。单击“确定”在此断点处停止。我搜索了答案,但他们说启用托管兼容模式,但没有用。 最佳答案 在项目调试设置下

c# - CS1501 : No overload for method 'ToString' takes 0 arguments?

ToString的无重载怎么可能采用零参数?零参数ToString是System.Object的一部分!编辑以回应接近投票:由于我无法将我的构建服务器升级到.NET4.5,有什么方法可以使此代码与.NET4.0/VS2010编译器?没有给我的重载一个完全不同的名称,这并不酷。所讨论的对象是一个F#区分联合,它覆盖了从System.Object继承的ToString方法。被覆盖的ToString正在被属于同一解决方案的C#项目中的代码调用。这一切都很好,直到我将ToString的额外重载添加到我的可区分联合中,它接受一个参数。这一切都在我的本地机器上完美构建和运行(VS2012,所有项目

c# - "public new virtual void Method()"是什么意思?

什么时候使用新的虚关键字修饰方法?什么是感情?比如定义一个接口(interface),然后添加一个类来继承这个接口(interface)。而是使用新的virtual来实现接口(interface)方法。interfaceIPrinter{voidPrint();}publicclassPrinterOne:IPrinter{publicvoidPrint(){Console.WriteLine("PrinterOne.");}}publicclassPrinterTwo:PrinterOne{publicnewvirtualvoidPrint(){Console.WriteLine("

c# - 分页列表错误 : The method 'OrderBy' must be called before the method 'Skip'

完整的错误信息如下:“Skip”方法仅支持LINQtoEntities中的排序输入。方法'OrderBy'必须在方法'Skip'之前调用在“PurchaseOrderController”中,我已将这段代码添加到索引方法中://GET:PurchaseOrderpublicActionResultIndex(int?page){returnView(db.PurchaseOrders.ToPagedList(page??1,3));}还在“PurchaseOrders”的索引View中,我添加了这段代码:@usingPagedList;@usingPagedList.Mvc;@mode

c# - 委托(delegate) : Method name expected error

我正在尝试让以下简单的委托(delegate)示例正常工作。根据我从中获取的一本书应该没问题,但我得到了一个Methodnameexpected错误。namespaceTestConsoleApp{classProgram{privatedelegatestringD();staticvoidMain(string[]args){intx=1;Dcode=newD(x.ToString());}}}有什么帮助吗? 最佳答案 删除():Dcode=newD(x.ToString);您想指定方法,而不是执行。

c# - .NET 4.5 中的代码契约 + 异步 : "The method or operation is not implemented"

在Windows7x64上的VS2012中使用CodeContracts1.4.51019.0时,我从ccrewrite收到以下编译错误:“方法或操作未实现."这似乎是由属性访问器的组合和使用缺少内部await的async方法引起的。复制步骤:创建一个启用“完整”运行时契约检查的新类库:namespaceCodeContractsAsyncBug{usingSystem.Threading.Tasks;publicclassService{//Offendingmethod!publicasyncTaskProcessAsync(Entityentity){varflag=entity