I am writing a script service (ScriptExecuter
) which execute scripts. the ScriptExecuter
class contains two virtual method ExecuteSQL
and CompileCSharp
.
Here is the code:
public class ScriptExecuter
{
public virtual bool ExecuteSQL(string query)
{
return false;
}
public virtual bool CompileCSharp(string code)
{
return false;
}
}
public class SQLExecuter : ScriptExecuter
{
public override bool ExecuteSQL(string query)
{
return true;
}
}
public class CSharpCompiler : ScriptExecuter
{
public override bool CompileCSharp(string query)
{
return true;
}
}
And here is my main method code:
public class Program
{
static void Main(string[] args)
{
var scriptExecuter=new ScriptExecuter();
var result = scriptExecuter.ExecuteSQL("SELECT * FROM Table1");
Console.WriteLine(result);
}
}
The output is false
. I want the value of the derived classes.
my question is: How can ScriptExecuter
return its derived class return value?