C# 类和结构中的时期

问题描述 投票:0回答:1

我总是在 C# 的类和结构中看到句点 (.)。例如在

JsonElement.ArrayEnumerator and Dictionary<TKey,TValue>.ValueCollection:

https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2.valuecollection?view=net-8.0 https://learn.microsoft.com/en-us/dotnet/api/system.text.json.jsonelement.arrayenumerator?view=net-8.0

这是否意味着它是该特定类中的嵌套类,或者是 JsonElement 命名空间的一部分,或者在类或结构的定义中使用句点是否合法?

c# oop
1个回答
0
投票

这称为“嵌套类型”。本质上,它的行为与附加命名空间非常相似,因为您只能访问封闭类的静态成员。但是,您不能在需要命名空间的地方使用 enclsoing 类型,例如在“using”指令中。

© www.soinside.com 2019 - 2024. All rights reserved.