2013-12-09 44 views
0

我在一個情況下,我需要有兩個重載看起來應該是這樣一個方法,重載方法類似簽名

void myMethod(string myParam) 
{ 
    // Some code to process myParam 
} 

void myMethod(string otherParam) 
{ 
    // Another code to process otherParam 
} 

不幸的是C#編譯器不允許這種超載,因爲它認爲兩個重載具有相同的簽名,如果要爲參數表示不同的含義,您將有不同的名稱。

我不知道該如何處理這種情況?

回答

1

你也許應該創建一個類來擴展這個類,然後你可以重載你的方法。