加号 (+) 出现在 C# 集合类型名称的字符串中

Jaz*_*mov 4 c# types visual-studio

我以前从未见过(或注意到)这一点,但在使用 C# 时,我在 Visual Studio 的直接窗口中的字符串中看到了一个加号 (+),它表示数据类型。

要了解我在说什么,请考虑以下简单的代码:

var myConverter = new System.ComponentModel.BooleanConverter();
var standardValuesCollection = myConverter.GetStandardValues();
Run Code Online (Sandbox Code Playgroud)

如果我进入 VS 立即窗口并输入以下内容:

?standardValuesCollection.GetType().ToString()
Run Code Online (Sandbox Code Playgroud)

Visual Studio 报告了这一点:

"System.ComponentModel.TypeConverter+StandardValuesCollection"
Run Code Online (Sandbox Code Playgroud)

请注意上面字符串“TypeConverter”后面的“+”。

然而,当我将鼠标悬停在代码中的standardValuesCollection上时,我只看到对预期 System.ComponentModel.TypeConverter.StandardValuesCollection 的引用:

在此输入图像描述

类型的立即窗口字符串描述中的加号表示什么?

Han*_*ing 6

这意味着 StandardValuesCollection 被定义为 TypeConverter 的子类:

namespace System.ComponentModel
{
    public class TypeConverter 
    {
        public class StandardValuesCollection  {}
    }
}
Run Code Online (Sandbox Code Playgroud)