예 : 작동하지 않는 것과 같은 (ref this) ... 예 : 실패 :C에서 현재 인스턴스 참조를 전달하는 방법
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CopyOfThis
{
class Program
{
static void Main(string[] args)
{
View objView = new View();
objView.Boo();
objView.ShowMsg("The objView.StrVal is " + objView.StrVal);
Console.Read();
}
} //eof Program
class View
{
private string strVal;
public string StrVal
{
get { return strVal; }
set { strVal = value; }
}
public void Boo()
{
Controller objController = new Controller(ref this);
}
public void ShowMsg (string msg)
{
Console.WriteLine(msg);
}
} //eof class
class Controller
{
View View { get; set; }
public Controller(View objView)
{
this.View = objView;
this.LoadData();
}
public void LoadData()
{
this.View.StrVal = "newData";
this.View.ShowMsg("the loaded data is" + this.View.StrVal);
}
} //eof class
class Model
{
} //eof class
} //eof namespace
좀 더 자세한 정보를 제공해 주시겠습니까? 응용 프로그램에 필요한 예제가 있으면 누군가가 대답하기가 더 쉬워 질 수 있습니다. –