how-to pass the reference of the current instance in C#
c#, reference
Solution
`this` is already a reference. Code like
DoSomethingWith(this);
is passing the reference to the current object to the method `DoSomethingWith`.
Problem
e.g. something like ( ref this ) which does not work ... E.g. this fails: ``` 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 ```