我想知道我是否可以获取调用静态类 ex 的静态方法的对象:
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) 的参数中传递它之外,是否有可能获得“Sender”?