當你輸入「this」。 ,你通常會獲得當前所在班級的所有例程,活動等等。而當你僅僅站在長列表中的一個例程而沒有選擇一個例程時,通常會在它旁邊獲得一個說明。如何獲得自定義創建的類的智能感知?
我該怎麼做?假設我有一個名爲CAR的類有兩個例程:speed_up()和brake()。 我怎樣才能讓使用我班看到的這兩個功能的描述,當他類型的人:
CAR mycar = new CAR();
mycar.
當你輸入「this」。 ,你通常會獲得當前所在班級的所有例程,活動等等。而當你僅僅站在長列表中的一個例程而沒有選擇一個例程時,通常會在它旁邊獲得一個說明。如何獲得自定義創建的類的智能感知?
我該怎麼做?假設我有一個名爲CAR的類有兩個例程:speed_up()和brake()。 我怎樣才能讓使用我班看到的這兩個功能的描述,當他類型的人:
CAR mycar = new CAR();
mycar.
以上一類或方法,而不是一個 「//」 的評論。如果你做了一個「///」三重斜槓(或者稱爲XML註釋),它會執行一個快捷方式,讓你填寫關於你正在評論的類或方法的信息。
這然後在代碼中出現這樣
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void Method(object sender, EventArgs e)
當你再通過智能感知,多數民衆贊成訪問類或方法時,描述將出現。
給你的類及其成員,XML comments,將出現在intellisense。在Visual Studio中最簡單的方法是在你想添加註釋的地方輸入///
。
例如:
/// <summary>
/// Class level summary documentation goes here.</summary>
/// <remarks>
/// Longer comments can be associated with a type or member through
/// the remarks tag.</remarks>
public class TestClass : TestInterface
{
/// <summary>
/// Store for the name property.</summary>
private string _name = null;
/// <summary>
/// The class constructor. </summary>
public TestClass() { }
/// <summary>
/// Description for SomeMethod.</summary>
/// <param name="s"> Parameter description for s goes here.</param>
/// <seealso cref="System.String">
/// You can use the cref attribute on any tag to reference a type or member
/// and the compiler will check that the reference exists. </seealso>
public void SomeMethod(string s)
{
}
}
上述發現here。
參見:How do you get XML comments to appear in a different project (dll)?
我覺得斜槓是另一種方式像'///' – V4Vendetta
哎呀,剛纔注意到了,謝謝。 –
試圖通過///
鍵控和填補像下面
/// <summary>
/// This is my speed up method
/// </summary>
public void speed_up(){ ...}
你能做到這一點每一個的方法和屬性,使得它有意義顯示在智能感知意圖添加總結你的方法。
你應該使用在Visual Studio中提供的XML文檔格式的每一種類型的結構(即類,方法,屬性...)
要訪問它,在你的聲明之前線型///。
例如:
///
public void Method(string p){...
你會得到這樣的:
/// <summary>
///
/// </summary>
/// <param name="p"></param>
public void Method(string p){...
如果鍵入/// <,你甚至會得到可用的XML元素的列表,如言論或爲例 欲瞭解更多信息,請參閱http://msdn.microsoft.com/en-us/magazine/cc302121.aspx
您可以將此意見放入:
/// <summary>
/// This sppeds up the car
/// </summary>
public void speed_up()
{ }
你必須把一個評論對這樣的:
/// <summary>
/// This is my function.
/// </summary>
/// <param name="myParameter">This parameter is very important.</param>
/// <returns>It returns always 42.</returns>
public int MyFunction(string myParameter)
{
return 42;
}
你可以描述的功能<summary>
的使用和PARAMATERS <param name="">
的意義。如果函數具有返回值,則可以使用標記<returns>
來描述它。當你在三個\
之後寫下你的評論時,有一些支持的mor標籤將被視覺工作室列出。
它很簡單。 :D謝謝。 – Fares
我發現了與名稱空間相結合的Intellisense問題:[link] http://stackoverflow.com/questions/23562307/intellisense-not-shown-on-public-classes-but-on-private-ones [link] can you確認? –