密封的类和对象浏览器 [英] Sealed classes and Object Browser

查看:188
本文介绍了密封的类和对象浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在对象浏览器"窗口中检查.net对象模型时,我发现缺少有关密封类的信息.

While inspecting the the .net object model in the Object Browser window, I came across the lack of information on sealed classes.

例如,如果有人导航到mscorlib容器-> 系统名称空间-> 字符串类,则详细信息窗格将显示以下内容:

If for instance, one navigates to the mscorlib container -> System namespace -> String class, the details pane displays the following:

公共类字符串
     系统成员

public class String
     Member of System

摘要:
将文本表示为一系列Unicode字符.

Summary:
Represents text as a series of Unicode characters.

属性:
[System.Runtime.InteropServices.ComVisibleAttribute(true), System.Reflection.DefaultMemberAttribute("Chars")]

Attributes:
[System.Runtime.InteropServices.ComVisibleAttribute(true), System.Reflection.DefaultMemberAttribute("Chars")]

似乎只能确定是通过代码定义窗口还是通过尝试从其派生来密封类.

It seems I can only ascertain if a class is sealed either through the Code Definition Window or, of course, by trying to derive from it.

然而,在安德鲁·特罗尔森(Andrew Troelsen)跟随Apress - Pro C# 2008 and the .Net 3.5 Platform的同时,作者在第188页上显示了对象浏览器如何显示密封状态:

Yet, while following Apress - Pro C# 2008 and the .Net 3.5 Platform, by Andrew Troelsen, the author shows on page 188 how the object browser display the sealed status:

此信息是否已从Visual Studio 2008对象浏览器中删除?我能以某种方式找回它吗?

尽管作者在全文中提到了Visual Studio 2008,但该屏幕截图必须来自以前的版本.该书实际上已经是第4版,并于2001年以.Net 1.0 Beta 2开始.

Although the author mentions Visual Studio 2008 throughout the text, that screenshot must be from a previous version. The book is in fact in its 4th Edition, and started back in 2001 with .Net 1.0 Beta 2.

推荐答案

我知道已经有几年了,但是我想确认我可以在VS2k8 SP1中看到它,但仅 用于String.

I know it's been a couple of years, but I'd just like to confirm I can see this in VS2k8 SP1, but only for String.

我认为这是因为String是唯一与IntegerLong等一起被标记为特殊"(也许是原始类型?)的class(都是ValueTypes( structures).

I think it is because String is the only class that has been marked as "special" (primitive type perhaps?) along with Integer, Long, etc, which are all ValueTypes (structures).

在问题SByteSingleString中的图像中注意的Lem树视图中的图标与现在一样.

Note in the image in the question SByte, Single and String do not have the same icon in the LHS treeview where as they do now.

又过了几年,我刚刚在VS2k8 SP1中注意到了VB.NET,当我有了对象浏览器时,它确实说了Public NotInheritable Class String浏览选择设置为我的项目"或所有组件" *,但是当我选择特定的.NET Framework时,仅设置为Public Class String(并且列出了属性,而其他浏览选择中没有这些属性).

It's been another couple of years and I've just noticed for VB.NET in VS2k8 SP1 it does say Public NotInheritable Class String when I have the Object Browser Browse selection set to My Project or All Components*, but only Public Class String when I select a specific .NET Framework (and yet Attributes are listed, whereas they're not in the other Browse selections).

*如在OP中捕获的显示中一样!

*As in the display captured in the OP!

NB仅当您关闭String并再次在LHS树视图上重新显示时,它才会更新显示. VS2010 SP1的行为相同.

NB It only updates the display if you shift off String and back on it again on the LHS treeview. And VS2010 SP1 behaves identically.

在VS2010中,对于.NET 4,我看到所有组件同时将String显示为NotInheritable,对于.NET 2和Silverlight,它们显示为空白",但是我目前无法确认VS2008在类似的情况.

In VS2010 I see All Components showing String as both NotInheritable, for .NET 4, and "blank" for .NET 2 and Silverlight, but I can't currently confirm what VS2008 shows in a similar situation.

这篇关于密封的类和对象浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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