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.
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.
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:
The example is written by me casually, mainly to give you a demonstration, the official document is here: