Reputation: 1842
I have the following base class:
abstract class DALBase
{
protected static EntityName ctx = null;
protected static EntityName GetCtx()
{
return new EntityName ();
}
}
Here is the class using the base:
public class MyClass : DALBase
{
public void Method1()
{
using(ctx = GetCtx())
{
Method2(ctx);
}
}
public void Method2(EntityName context) <---- Here I want to avoid using EntityName
{
context....
}
}
Is there a way to pass the context from one method to another without having to use the entity name of EntityName so the only place I have it declared is in the base class? Thanks.
Upvotes: 1
Views: 1444
Reputation: 13188
In reality you already can do it. I just created an overloaded Method2(), with no parameters, and called ctx from within it with no problem. ctx is already a local variable inherited from DALBase and is accessible from any MyClass methods.
Upvotes: 2