草庐IT

virtual-inheritance

全部标签

c# - 为什么我会收到 "The modifier ' virtual'is not valid for this item“错误?

我正在尝试使用以下模型创建mvc应用程序:(代码很大。我认为它对您来说更容易理解)publicclassJob{publicintJobId{get;set;}publicstringName{get;set;}publicListGetJobs(){ListjobsList=newList();jobsList.Add(newJob{JobId=1,Name="Operator"});jobsList.Add(newJob{JobId=2,Name="Performer"});jobsList.Add(newJob{JobId=3,Name="Head"});returnjobsLi

c# - IIs 错误 : Application Codebehind =“Global.asax.cs” Inherits =“nadeem.MvcApplication”

我正在尝试部署我的Web项目,但我不断收到此错误:Line1:我看了这篇文章:ParserError:ServerErrorin'/'Application但它在我的项目中是正确的。我怀疑它与我的iis7配置有关。有什么想法吗?全局.asax:Global.asax.cs:namespaceTamalTest{usingSystem;usingSystem.Web;usingSystem.Web.Mvc;usingSystem.Web.Routing;publicclassMvcApplication:HttpApplication{protectedvoidApplication_S

C# : Transitive Inheritance

继承是C#中的传递关系吗?我问是因为我不明白为什么IList工具ICollection和IEnumerable作为ICollection已经实现IEnumerable感谢您为我澄清这一点。 最佳答案 它在所有方面都是可传递的。可能您用来查看继承层次结构的工具具有特定的显示方式。无法取消实现接口(interface),尽管您可以显式实现它,从而对智能感知隐藏它。作为IList的作者,您可以自由选择仅派生自ICollection还是派生自ICollection和IEnumerable。在这种情况下,IEnumerable将是多余的并由r

c# - Entity Framework 4.1 RC : Code First EntityTypeConfiguration inheritance issue

我正在尝试使用一个通用的EntityTypeConfiguration类来为我的所有实体配置主键,以便每个派生配置类不会重复自身。我的所有实体都实现了一个通用接口(interface)IEntity(表示每个实体都必须有一个int类型的Id属性)。我的配置基类如下所示:publicclassEntityConfiguration:EntityTypeConfigurationwhereTEntity:class,IEntity{publicEntityConfiguration(){HasKey(e=>e.Id);Property(e=>e.Id).HasDatabaseGenerat

c# - 注册抛出 'Inheritance security rules violated while overriding member'

对于我的学校项目,我正在使用MVC项目附带的默认帐户Controller注册函数://POST:/Account/Register[HttpPost][AllowAnonymous][ValidateAntiForgeryToken]publicasyncTaskRegister(RegisterViewModelmodel){if(ModelState.IsValid){varuser=newApplicationUser(){UserName=model.UserName};varresult=awaitUserManager.CreateAsync(user,model.Pass

c# - cocos2d-xna : sprite is not drawn if using instance of a class inherited from sprite

我有一个基于Cocos2DXNA和MonoGame的游戏项目。我想在CCSprite类中添加一些自定义逻辑,所以我创建了一个继承自CCSprite的类。我添加了一个虚拟自动属性并尝试使用此类,但出于某种原因,作为我的自定义Sprite类实例创建的Sprite未显示在图层上,而作为CCSprite类实例的Sprite完全没问题。代码如下所示:publicclassSprite:CCSprite{publicstringSomeProp{get;set;}}...line1:varmySprite1=newSprite("texture.png");line2:varmySprite1=n

c# - ListView 控件中的闪烁(OwnerDraw、Virtual)

这个问题可能被认为是Flickeringinlistviewwithownerdrawandvirtualmode的后续问题.我在虚拟模式中有一个ListView控件,我尝试执行自定义绘图。项目渲染是通过以下方法覆盖完成的:protectedoverridevoidOnDrawItem(DrawListViewItemEventArgseventArgs)如引用问题中所述,自定义绘图会在鼠标悬停事件时引入闪烁。调试器告诉我发生这种情况是因为触发了过多自定义绘制事件。现在-所引用问题的公认答案告诉我们:Thisisabugin.NET'sListViewandyoucannotgetar

C# - "destructors are not inherited"实际上是什么意思?

C#LanguageSpecification3.0的第10.13节,析构函数声明如下:Destructorsarenotinherited.Thus,aclasshasnodestructorsotherthantheonewhichmaybedeclaredinthatclass.C#ProgrammingGuide的析构函数部分包含一个示例,演示如何调用继承层次结构中的析构函数,包括以下语句:...thedestructorsforthe...classesarecalledautomatically,andinorder,fromthemost-derivedtotheleas

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

c# - MVC 5 : Should I inherit my User from IdentityUser class?

我正在尝试学习Asp.NetIdentity和在这个tutorial,在Models\AppModels,cs部分创建EntityFramework代码优先ToDo模型MyUser类(class)继承自IdentityUser类和MyDbContext继承自IdentityDbContext类(class)。这是为什么?假设我有一个User包含我的Web应用程序用户的所有信息的类,该类是否应该继承自IdentityUser,我的DbContext是否应该继承?继承自IdentityDbContext?此外,从IdentityDbContext继承dbcontext类的优点是什么?平原D