M
Mucahit ikiz
Hello,
First of all, I created Base Form called "tureyen_frm".
Then i created a new form by inheritance using the Base Form. This name is
"tureten" form.
For each new form derived from the Base Form a , I created a class.
And than some methods in Base Windows Form use in the the derivate forms
class.
Some of the methods in the Base Form need to use classes of the derivative
forms.
Of cours, I make a reference from derivative Forms to Base Form in a CLASS
At this point I need establish a reference from the Base Form to the
classes in the derivative forms.
but, I get this error.
"Object reference not set to an instance of an object."
Please, How can i do,
Thanks in advance
Apologies for my English
This is order operation
1.Operation
I created Interface.
using System;
using System.Collections.Generic;
using System.Text;
namespace inttest.Interfaces
{
public interface Iadsoyad
{
string ad { get;}
string soyad { get;}
}
}
2.Operation
I derived a class from interface.
using System;
using System.Collections.Generic;
using System.Text;
using inttest.Interfaces;
namespace classsharp
{
public class cls_adsoyad : Iadsoyad
{
public string _ad=string.Empty;
public string _soyad=string.Empty;
public string ad
{
get { return _ad; }
}
public string soyad
{
get { return _soyad; }
}
public cls_adsoyad()
{
}
public cls_adsoyad(string adi, string soyadi)
{
_ad = adi;
_soyad = soyadi;
}
}
}
3.Operation
I created a Base Form and name is "tureyen_frm".
This form will be used as a Base Form the derivative forms that will
inherit from the base form.
The methods in the Base Form be executed in the derived form.
so, i am using The Interface in Base Form.
I use the classes of the derivative forms from the Base Form.
derivative forms
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using inttest.Interfaces;
namespace sharptest
{
public partial class tureyen_frm : Form
{
protected Iadsoyad tr_adsoyad;
string isim = string.Empty;
public tureyen_frm()
{
InitializeComponent();
}
private void tureyen_frm_Load(object sender, EventArgs
e)
{
isim = tr_adsoyad.ad;
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(isim.ToString());
}
}
}
4.Operation
I created derivative Form from the Base Form , this name is "turetilen"
form.
And call it;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using classsharp;
namespace sharptest
{
public partial class turetilen : tureyen_frm
{
public turetilen()
{
InitializeComponent();
cls_adsoyad ogrenci=new cls_adsoyad("Ali","Okur");
}
private void tureyen_frm_Load(object sender, EventArgs
e)
{
;
}
}
}
5.Operation
And than i make debug step by step.
This script get error "cls_adsoyad ogrenci=new
cls_adsoyad("Ali","Okur");"
This error message is "Object reference not set to an instance of an
object."
Can you help me? in anyone.
First of all, I created Base Form called "tureyen_frm".
Then i created a new form by inheritance using the Base Form. This name is
"tureten" form.
For each new form derived from the Base Form a , I created a class.
And than some methods in Base Windows Form use in the the derivate forms
class.
Some of the methods in the Base Form need to use classes of the derivative
forms.
Of cours, I make a reference from derivative Forms to Base Form in a CLASS
At this point I need establish a reference from the Base Form to the
classes in the derivative forms.
but, I get this error.
"Object reference not set to an instance of an object."
Please, How can i do,
Thanks in advance
Apologies for my English
This is order operation
1.Operation
I created Interface.
using System;
using System.Collections.Generic;
using System.Text;
namespace inttest.Interfaces
{
public interface Iadsoyad
{
string ad { get;}
string soyad { get;}
}
}
2.Operation
I derived a class from interface.
using System;
using System.Collections.Generic;
using System.Text;
using inttest.Interfaces;
namespace classsharp
{
public class cls_adsoyad : Iadsoyad
{
public string _ad=string.Empty;
public string _soyad=string.Empty;
public string ad
{
get { return _ad; }
}
public string soyad
{
get { return _soyad; }
}
public cls_adsoyad()
{
}
public cls_adsoyad(string adi, string soyadi)
{
_ad = adi;
_soyad = soyadi;
}
}
}
3.Operation
I created a Base Form and name is "tureyen_frm".
This form will be used as a Base Form the derivative forms that will
inherit from the base form.
The methods in the Base Form be executed in the derived form.
so, i am using The Interface in Base Form.
I use the classes of the derivative forms from the Base Form.
derivative forms
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using inttest.Interfaces;
namespace sharptest
{
public partial class tureyen_frm : Form
{
protected Iadsoyad tr_adsoyad;
string isim = string.Empty;
public tureyen_frm()
{
InitializeComponent();
}
private void tureyen_frm_Load(object sender, EventArgs
e)
{
isim = tr_adsoyad.ad;
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(isim.ToString());
}
}
}
4.Operation
I created derivative Form from the Base Form , this name is "turetilen"
form.
And call it;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using classsharp;
namespace sharptest
{
public partial class turetilen : tureyen_frm
{
public turetilen()
{
InitializeComponent();
cls_adsoyad ogrenci=new cls_adsoyad("Ali","Okur");
}
private void tureyen_frm_Load(object sender, EventArgs
e)
{
;
}
}
}
5.Operation
And than i make debug step by step.
This script get error "cls_adsoyad ogrenci=new
cls_adsoyad("Ali","Okur");"
This error message is "Object reference not set to an instance of an
object."
Can you help me? in anyone.