草庐IT

abstract-base-class

全部标签

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# - CA2104 警告 : Is there any way to mark a class as `Immutable` to suppress it?

考虑下面的代码,它触发了CA2104:Donotdeclarereadonlymutablereferencetypes.publicclassTest{//ThisprovokesCA2104:"Donotdeclarereadonlymutablereferencetypes".protectedreadonlyImmutableClassImmutableMember;}publicclassImmutableClass{}有谁知道以一种可以抑制警告CA2104的方式将类标记为不可变的方法吗?我尝试用[ImmutableObject(true)]装饰MutableClass没有成

c# - FileLoadException 在 InitializeComponent 或 x :Class=

我在InitializeComponent方法中遇到文件加载器异常(第一次机会),或者调试器在多个WPF的xaml-root的x:Class属性处中断用户控制。尽管异常会大大降低导航速度,但一切正常。这是异常信息:Couldnotloadfileorassembly'Company.Solution.UserInterface,Version=0.1.5568.25577,Culture=neutral,PublicKeyToken=45069ab0c15881ce'oroneofitsdependencies.Thelocatedassembly'smanifestdefinitio

c# - 为什么具有 "where T : class"约束的 Generic<T> 方法接受接口(interface)

我有这个interface:publicinterfaceITestInterface{intTestInt{get;set;}}和这个通用方法(带有T:class约束):publicvoidTest()whereT:class{//DoSomething}这个电话:Test();一切都编译并运行,同时interface不是class(或者是吗?)。为什么会这样?我第一次看到这个是在我的WCF代理类上:publicpartialclassTestServiceClient:System.ServiceModel.ClientBase,TestNamespace.ITestService

c# - 代码契约(Contract) : Why are some invariants not considered outside the class?

考虑这个不可变类型:publicclassSettings{publicstringPath{get;privateset;}[ContractInvariantMethod]privatevoidObjectInvariants(){Contract.Invariant(Path!=null);}publicSettings(stringpath){Contract.Requires(path!=null);Path=path;}}这里需要注意两点:有一个保证Path属性永远不会为null的契约不变量构造函数检查path参数值以遵守先前的契约不变量此时,Setting实例永远不能有n

c# - Visual Studio express : free class diagram tool

关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。关闭8年前。Improvethisquestion我正在使用c#express并希望使用免费工具来设计我的类图。您有什么推荐的免费工具?

c# - 解码/解密期间 Base-64 字符数组的长度无效

问:我面临以下大问题:我不时发现以下异常:Base-64字符数组的长度无效我使用加密和解密:publicstaticstringEncrypt(stringtext){try{key=Encoding.UTF8.GetBytes(stringKey.Substring(0,8));DESCryptoServiceProviderdes=newDESCryptoServiceProvider();Byte[]byteArray=Encoding.UTF8.GetBytes(text);MemoryStreammemoryStream=newMemoryStream();CryptoStr

c# - .NET 属性生成 "must declare a body because it is not marked abstract or extern"编译错误

我有一个.NET3.5(目标框架)网络应用程序。我有一些看起来像这样的代码:publicstringLogPath{get;privateset;}publicstringErrorMsg{get;privateset;}它给我这些行的编译错误:"mustdeclareabodybecauseitisnotmarkedabstractorextern."有什么想法吗?我的理解是这种风格的属性在.NET3.0中是有效的。谢谢!原来问题出在我的.sln文件本身。尽管我在构建选项中更改了目标版本,但在.sln文件中,我发现了这一点:TargetFramework="3.0"将其更改为“3.5

c# - WPF 数据绑定(bind) : enable/disable a control based on content of var?

我的表单上有一个按钮,只有在TreeView(或tabitem中的ListView)中选择了一个项目时才应启用该按钮。选择一个项目时,它的值存储在一个字符串成员变量中。我可以将按钮的IsEnabled属性绑定(bind)到成员var的内容吗?也就是说,如果成员var不为空,则启用该按钮。同样,当成员变量的内容发生变化(设置或清除)时,按钮的状态也应发生变化。 最佳答案 由于您可能希望根据字符串绑定(bind)按钮的IsEnabled属性,请尝试为它创建一个转换器。即...和转换器:[ValueConversion(typeof(st

c# - 通过反射仅获取当前类(class)成员

假设这段代码:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Reflection;namespaceTestFunctionality{classProgram{staticvoidMain(string[]args){//System.Reflection.Assembly.GetExecutingAssembly().LocationAssemblyassembly=Assembly.LoadF