我想知道如果我能得到物體稱爲靜態類的靜態方法 例如:嵌套靜態類C#
public class Person
{
private static class TelephoneLine
{
public static string sharedString = string.Empty;
public static void NotifyOnCall()
{
//notify if someone call this person
}
public static void Comunicate(Person comunicateWith, string message)
{
sharedString = "Sender: " /* Object which called that method */ + " To: " + comunicateWith.Name +
" said: " + message;
}
}
public Person(string name)
{
Name = name;
}
string Name;
public void CallTo(Person person, string message)
{
TelephoneLine.Comunicate(person, message);
}
public void ShowCall()
{
Console.Write(TelephoneLine.sharedString);
}
}
}
那麼,有沒有可能獲得「發件人」只是路過它在ThelephoneLine.Comunicate(this,comunicateWith,msg)的參數中?
如何關係到(嵌套)靜態類這個問題:
事實上,TelephoneLine對象應該被別的東西所擁有? – CodesInChaos 2011-06-09 14:32:18