草庐IT

return-type-requirement

全部标签

c# - "Inspecting the state of an object in the debuggee of type System.Reflection.MethodBase is not supported in this context"

我不知道这个错误是什么意思。我使用的是VisualStudioforMac7.5.0社区版。我在带有ASP.NETCore的EntityFramework中使用延迟加载。publicpartialclassAdminUser{publicAdminUser(){RoleAssign=newHashSet();}publicGuidUserId{get;set;}publicstringFirstName{get;set;}publicstringLastName{get;set;}publicstringEmail{get;set;}publicstringUserName{get;s

c# - 比 Dictionary<Type, X> 更快的选择?

我正在创建一个正在进行性能测试的库。在其中我生成了一个Dictionary一次。这些项目当前以随机顺序插入。字典在应用程序生命周期内保持不变。然后它经常用于查找项目。查找是库中较大的瓶颈之一。是的,我正在微观优化,但要学习。我想知道是否有更好的方法来获得查找性能?更新我使用dotTrace来衡量性能。报告+dotTrace在我的家用电脑中,所以我这里没有报告(本可以上传到其他地方)。我使用了这里的测试:https://github.com/danielpalme/IocPerformance字典定义可在此处找到:https://github.com/jgauffin/Griffin.C

c# - 如何找到asp :Login LoginError error type

当asp:Login控件的LoginError事件触发时,我如何找到错误发生的原因?是否有类似e.ErrorType的属性告诉我登录失败的原因?或者我是否必须像本教程中那样手动检查所有内容:http://www.asp.net/security/tutorials/validating-user-credentials-against-the-membership-user-store-cs或http://www.aspnettutorials.com/tutorials/controls/howto-errors-login-asp4-csharp.aspx

c# - yield return 是可重入的吗?

是否可以从多个线程调用使用yieldreturn安全返回IEnumerable的静态类中的静态函数?publicstaticIEnumerableFooClassObjects(){foreach(FooClassWrapperobjinlistOfFooClassWrappers){yieldreturnobj.fooClassInst;}}是否每个调用它的线程都会收到对集合中每个对象的引用?在我的情况下,listOfFooClassWrappers在程序开始时被写入一次,所以我不需要担心它在调用此函数期间发生变化。我编写了一个简单的程序来对此进行测试,但我没有看到任何问题迹象,但线

c# - nest yields to return IEnumerable<IEnumerable<T>> with lazy evaluation

我写了一个LINQ扩展方法SplitBetween类似于String.Split.>newList(){3,4,2,21,3,2,17,16,1}>.SplitBetween(x=>x>=10)[3,4,2],[3,2],[],[1]来源://partitionsequenceintosequenceofcontiguoussubsequences//behaveslikeString.SplitpublicstaticIEnumerable>SplitBetween(thisIEnumerablesource,FuncseparatorSelector,boolincludeSepa

c# - 使用泛型类型参数代替 System.Type 类型的参数。是气味吗?

关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭3年前。Improvethisquestion我经常看到(例如在许多模拟库中)使用泛型类型参数代替System.Type类型参数的方法。我特别讨论的是泛型类型仅在typeof(T)操作中使用的情况(即,方法中的任何地方都没有使用类型T的实例,并且T没有被用于返回值类型或其他参数)。例如考虑以下方法:publicstringGetTypeName(System.Typetype){returntype.FullName;}这个方法通常伴

c# - CA1819 : Properties shouldn't return arrays - What is the right alternative?

我以前遇到过这个FxCop规则,但对如何解决违规问题并不满意(thread1、thread2)。我现在有另一个案例,我需要纠正违反CA1819的行为亲切。具体来说,我有一个算法库,它使用如下所示的公共(public)“输入对象”对曲线(x,y)执行一些分析计算:publicclassInputObject{publicdouble[]X{get;set;}publicdouble[]Y{get;set;}//+lotsofotherthingswell}此对象的X和Y属性在库中的数百个位置使用,通常使用索引。输入对象永远不会被算法改变,但实际上如果是这样也无关紧要。另外,.Length

c# - 异步任务<IEnumerable<T>> 抛出 "is not an iterator interface type"错误

仅当我使用async时,下面的代码才会抛出isnotaniteratorinterfacetypeawait并包装IEnumerable与任务。如果我删除asyncawait,它将与IEnumerable>一起使用.privateasyncTask>>GetTableDataAsync(CloudTablecloudTable,TableQuerytableQuery)whereT:ITableEntity,new(){TableContinuationTokencontineousToken=null;do{varcurrentSegment=awaitGetAzureTableDa

c# - 调用使用 yield 返回的方法时出现错误 'Iterator cannot contain return statement '

我希望有更好的方法来编写此方法和重载,同时减少代码重复。我想返回列表中项目之间的一系列增量。这个方法:-publicstaticIEnumerableCalculateDeltas(thisIEnumerablesequence){decimalprev=default(decimal);foreach(variteminsequence){varcurrent=item;decimaldiff=current-prev;prev=item;yieldreturndiff;}}工作得很好。然后我想到了一个允许绝对增量的重载,但如果不需要绝对值,则会调用原始方法:-publicstati

C# 设计 : Why is new/override required on abstract methods but not on virtual methods?

为什么抽象方法需要new/override而虚方法不​​需要?示例1:abstractclassShapesClass{abstractpublicintArea();//abstract!}classSquare:ShapesClass{intx,y;publicintArea()//Error:missing'override'or'new'{returnx*y;}}编译器会显示这个错误:要使当前成员覆盖该实现,请添加override关键字。否则添加新关键字示例2:classShapesClass{virtualpublicintArea(){return0;}//itisvirt