我在使用Visual C#for Windows Phone中的某些代碼時遇到了一些麻煩 問題不在於它不起作用,因爲它的確如此,但我不明白如何使用P 在一個靜態類,創建一個靜態方法,這給本身作爲一個參數:在靜態方法中傳遞此參數作爲參數
public static void MethodONe(this Timeline animation)
{
//this class does not extend the TimeLine class, and is not connected to it in any
//such way.
animation.MethodTwo();
}
public static void MethodTwo(this Timeline animation)
{
someCode();
}
怎麼叫這個parameterpassing,以及它有什麼作用,到底是什麼?
可能重複[?什麼是擴展方法(http://stackoverflow.com/questions/403539/what-are-extension - 方法),[擴展方法](http://stackoverflow.com/questions/5730013/extension-methods),[爲什麼我們在擴展方法中使用「this」](http://stackoverflow.com/questions/2574311 /爲什麼我們使用這種擴展方法) – 2012-01-11 12:42:11