Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
516 views
in Technique[技术] by (71.8m points)

c# - 如何仅在C#编辑器IntelliSense中隐藏公共类?(How to hide public classes from being seen in C# Editor IntelliSense only?)

Shortly,

(不久,)

The Browsable() and EditorBrowsable() works with members.

(EditorBrowsable() Browsable()EditorBrowsable()与成员一起使用。)

not class itself.

(不上课本身。)

So, I need to hide the accessibility of class that I can't make it internal.

(因此,我需要隐藏无法将其设置为内部的类的可访问性。)

Just hide it from code.

(只需将其从代码中隐藏即可。)

An internal access modifier will make it only accessible in assembly the class created.

(internal访问修饰符将使其只能在汇编中访问创建的类。)

Why i need that?

(为什么我需要那?)

I need some people can't access these classes.

(我需要有些人无法访问这些课程。)

only I need writing it manually without showing in IntelliSense.

(只有我需要手动编写它,而无需在IntelliSense中显示。)

Updated

(更新)

I mean all kind of types [ classes, structs, enums ].

(我的意思是所有类型的[类,结构,枚举]。)

When user or developer write for example Employee class it will not showing in intellisense.

(当用户或开发人员编写例如Employee类时,它不会以智能提示显示。)

but its accessible and can be instantiated normally.

(但可以访问,并且可以正常实例化。)

  ask by deveton translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The answer depends, where the class is located.

(答案取决于课程所在的位置。)

If it's the same solution, you can't hide it, by design, as it described in this article

(如果是相同的解决方案,则无法按本文所述将其隐藏起来)

It won't hide them from you because you are the developer (of the solution) not the user (of the assembly).

(它不会对您隐藏它们,因为您是(解决方案的)开发人员而不是(程序集的)用户。)

For the class in a separate assembly you can apply the [EditorBrowsable(EditorBrowsableState.Never)] attribute together with [Browsable(false)]

(对于单独程序集中的类,可以将[EditorBrowsable(EditorBrowsableState.Never)]属性与[Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] [Browsable(false)])


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...