That Keyword
Brian Keller posed a question to the readers of his blog asking what we thought, if there were such a thing, the "that" keyword should do in C#. What a fantastic idea! My suggestion - the that keyword would be used to allow access to inherited classes from the base class.
public class MyBase
{
public MyBase()
{
//only call CallToMethod() in a specific class
if( typeof(that).ToString().Equals("MyChild") )
that.CallToMethod();
}
}
public class MyChild : MyBase
{
public void CallToMethod()
{
// more code goes here...
}
}
Yeah I know it's really dangerous and would definitely have some overhead associated with it but the functionality would be awesome!
Let's talk about this