非抽象 C# 类中的无体构造函数 [英] Bodyless constructor in non-abstract C# class

查看:28
本文介绍了非抽象 C# 类中的无体构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试理解 MVC 框架中提供的以下类;看起来这个类应该是抽象的,但它不是,但是这个类可以编译.尽管缺少抽象"关键字,但该类实际上是抽象的吗?我在这里错过了什么?

I'm trying to understand the following class provided in the MVC framework; it seems like the class should be abstract, but it is not, and yet this class compiles. Is the class actually abstract despite the missing "abstract" keyword? What am I missing here?

namespace Microsoft.AspNet.Identity.EntityFramework
{
    public class IdentityUser : IUser
    {
        public IdentityUser();
        public IdentityUser(string userName);

        public virtual ICollection<IdentityUserClaim> Claims { get; }
        public virtual string Id { get; set; }
        public virtual ICollection<IdentityUserLogin> Logins { get; }
        public virtual string PasswordHash { get; set; }
        public virtual ICollection<IdentityUserRole> Roles { get; }
        public virtual string SecurityStamp { get; set; }
        public virtual string UserName { get; set; }
    }
}

经验教训:如果没有为二进制文件提供源代码,在 Visual Studio 中使用Go To Definition"将提供一些看起来很像源代码的东西……这与在 Eclipse 中使用Open Declaration"不同,后者将向您展示一些看起来不像来源的东西.

Lesson learned: if there is no source provided for a binary, using "Go To Definition" in Visual Studio will provide something that looks mostly like source code... which is different than using "Open Declaration" in Eclipse, which will show you something that really doesn't look like source.

推荐答案

这是一个 Microsoft 类,我假设您通过 Visual Studio 中的转到定义"上下文菜单检索了其代码.此代码是通过反射类型自动生成的,仅用于显示声明而不是实现内容.如果您使用 .NET Refector 或 dotReflect 工具,那么您将看到实现的主体.

This is a Microsoft's class which I presume you retrieved the code for by "Go to Definition" context menu in Visual Studio. This code is auto generated by reflecting over the type, and only is meant to show declarations and not the implementation content. If you use .NET Refector or dotReflect tools, then you'll see body of the implementation.

这篇关于非抽象 C# 类中的无体构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆