Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-2024-08-06· OpenAIAi2 WildChat-4.8M (AI2)

how to make method not show in tooltip c# like i have method that is part of my library…

  1. User

    how to make method not show in tooltip c# like i have method that is part of my library and should be visible outside, but i cannot make it internal

  2. Assistant

    In C#, if you want to create a method in your library that is publicly accessible but you do not want it to appear in Intellisense tooltips when your library is used, you can use the EditorBrowsable attribute. This attribute allows you to control how methods and properties are displayed in the code editor.

    Here's how you can use the [EditorBrowsable] attribute to achieve this:

    using System;
    using System.ComponentModel;
    
    namespace YourLibrary
    {
        public class YourClass
        {
            [EditorBrowsable(EditorBrowsableState.Never)]
            public void YourMethod()
            {
                // Method implementation
            }
        }
    }
    

    Explanation:

    • [EditorBrowsable(EditorBrowsableState.Never)]: This attribute indicates that the method should not be shown in Intellisense tooltips. You can apply it to methods, properties, or any member of your class.

    • EditorBrowsableState.Never: This sets the visibility state of the method to "Never", meaning it will not appear in the Intellisense tooltips of the code editor even though it is publicly accessible and can still be called by fully typing out its name.

    Note that this will only affect the design-time experience in environments like Visual Studio that respect the EditorBrowsable attribute; the method remains callable as normal. Also, users of environments that do not respect this attribute may still see the method in their Intellisense tooltips.