1

I know that i need to add ///<summary> to have mouse over tips on functions and variables but is there a way to make this happen only with the // ?

In the pre-built default functions i always see a summary like this

// // Summary: // Tip. 

and it works fine when i over my mouse on that function, but this doesn't happen when i do it for one of my own variable or function.

Is there a way to make something like this work?

// Tip for information string information; information = "Speed of light is 300000 Km per Second"; 

When i over on information it should show me Tip for information.

2
  • 4
    That's not how these kinds of comments work, they are for public members that are visible outside of your class. Also, if thing you need comments like this, then that is a bit of a code smell that your code is poorly written in the first place. Commented Feb 20, 2023 at 11:54
  • Write a demo for you, see my answer. :) Commented Feb 21, 2023 at 8:11

1 Answer 1

2

Update:

The usage you see is triple-slash comments(one type of XML documention comment). If you want the following to achieve the same thing

// Tip for information string information; information = "Speed of light is 300000 Km per Second"; 

Then the answer is NO. There doesn't have such feature.

Original Answer:

This is a type of XML documentation comment, specifically, it's called "triple-slash comments"

Just like its name, you only need to press the slash key three times on the line before the definition after defining the property or method, and VS will automatically fill in the content for you (of course, you can also write it all by yourself.)

Triple-slash comment is usually used to describe the role and usage of members such as methods, attributes, classes, etc.

Here is an example, I think it will help you:

using System; namespace xxx { internal class Program { static void Main(string[] args) { var bowman = new Person { Name = "Bowman", Age = 25, Information = "xxx" }; var result = bowman.SayHello(); Console.WriteLine(result); } } public class Person { /// <summary> /// The name of the person. /// </summary> public string Name { get; set; } /// <summary> /// The age of the person. /// </summary> public int Age { get; set; } /// <summary> /// Speed of light is 300000 Km per Second /// </summary> public string Information { get; set; } /// <summary> /// This method is to say hello. /// </summary> /// <returns></returns> public string SayHello() { return this.Name + " Say Hello to you."; } } } 

And the performance:

enter image description here

The example is written by me casually, mainly to give you a demonstration, the official document is here:

XML documention comments

Sign up to request clarification or add additional context in comments.

1 Comment

yes thanks for the demo, but i thought it could show me the over tip information even with double slashesh on something only ( // ), but i guess it is not possible yet.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.