0

Shortly,

The Browsable() and EditorBrowsable() works with members. 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.

Why i need that?

I need some people can't access these classes. only I need writing it manually without showing in 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. but its accessible and can be instantiated normally.

deveton
  • 291
  • 4
  • 26
  • It's not clear what you are wanting... it sounds like you want to have public classes that people can still use, but you want to prevent them from showing up in IntelliSense? Why? – Herohtar Dec 01 '19 at 03:11
  • 1
    why isn't important. but how is important. its self convenient for me. – deveton Dec 01 '19 at 03:20
  • 1
    Why *is* important, because there is no reason to do so. I'm fairly certain it's not possible though. – Herohtar Dec 01 '19 at 03:22
  • 3
    You don't have 500 rep to give. – Herohtar Dec 01 '19 at 03:22
  • 1
    It depends, where the class is located. If it's the same solution, you can't hide it, by design, as it described in this [thread](https://social.msdn.microsoft.com/Forums/en-US/c2d2bd5a-97a5-4886-846d-759173476631/why-does-editorbrowsable-not-hide-methods-in-intellisense?forum=csharpide) For the class in separate assembly you can use solution from this [thread](https://stackoverflow.com/questions/9274784/hide-abstract-classes-from-intellisense) or this [answer](https://stackoverflow.com/a/9086419/4728685) `EditorBrowsable` is working, but not for the classes in the same solution – Pavel Anikhouski Dec 01 '19 at 09:35
  • Pavel Anikhouski. would you mind to answer it to make it solved. and Yes MSDN link you provided works. it must be in assembly not solution. – deveton Dec 01 '19 at 12:58

1 Answers1

3

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)]

Pavel Anikhouski
  • 21,776
  • 12
  • 51
  • 66