the following code does not work as I would expect:
using System;
using System.Data;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
MyClass cl = new MyClass();
cl.doSomething();
}
}
public class MyClass : BaseClass
{
protected override void doSelect(DataTable dt)
{
dt = null;
}
public void doSomething()
{
base.Fill();
}
}
public class BaseClass
{
private DataTable dtMain = null;
protected virtual void doSelect(DataTable dt)
{
}
protected void Fill()
{
dtMain = new DataTable();
this.doSelect(dtMain);
if (dtMain == null)
Console.WriteLine("as I would expect");
else
Console.WriteLine("why not changed???");
}
}
}
I tested it with other reference types, but same behavior. Is this a framework bug? When I use the ref keyword it works as I expect:
protected virtual void doSelect(ref DataTable dt)
{
} and so on
Would be nice I anyone could help me with this!