J
jkv
Hi,
I have recently migrated from Python to C# and i am having some
trouble passing reference when creating a instance.
My problem is that when i create a instance in the MainWindow
constructor i cannot access that instance (testing) from outside the
constructor.
If i move the "DataReader testing = new DataReader(this);" outside the
constructor i cannot pass the reference to 'this' anymore.
Any hints?
regards,
Johnny
namespace ms_csharp
{
public partial class MainWindow : Form
{
public MainWindow()
{
InitializeComponent();
DataReader testing = new DataReader(this);
}
}
AnotherForm.cs:
namespace ms_csharp
{
public class DataReader
{
public DataReader(MainWindow bah)
{
_MainWindow = bah;
}
}
I have recently migrated from Python to C# and i am having some
trouble passing reference when creating a instance.
My problem is that when i create a instance in the MainWindow
constructor i cannot access that instance (testing) from outside the
constructor.
If i move the "DataReader testing = new DataReader(this);" outside the
constructor i cannot pass the reference to 'this' anymore.
Any hints?
regards,
Johnny
namespace ms_csharp
{
public partial class MainWindow : Form
{
public MainWindow()
{
InitializeComponent();
DataReader testing = new DataReader(this);
}
}
AnotherForm.cs:
namespace ms_csharp
{
public class DataReader
{
public DataReader(MainWindow bah)
{
_MainWindow = bah;
}
}