G
Guest
Hey,
public class Sessie : SessieBase
{
public Contract Contract;
public Sessie()
{
Contract Contract = new Contract ();
this.Contract = Contract;
}
}
public class ContractBase
{
private string mContractNr;
public string ContractNr
{
get
{
return mContractNr;
}
set
{
mContractNr = value;
}
}
private Status mStatusCd;
public Status StatusCd
{
get
{
return mStatusCd;
}
set
{
mStatusCd = value;
}
}
public ContractBase()
{
this.StatusCd = new Status();
}
}
public class Contract: ContractBase
{
}
Somewhere in the code I want to that :
this.TxtContractnr.Text = (this.Sessie.Contract.ContractNr == null ? "" :
this.Sessie.Contract.ContractNr.ToString());
this.TxtStatus.Text = (this.Sessie.Contract.StatusCd.Desc == null ? "" :
this.Sessie.Contract.StatusCd.Desc.ToString());
I receive : A first chance exception of type 'System.ArgumentNullException'
occurred in system.windows.forms.dll
Additional information: Value cannot be null.
But that is just the test I will do.
In first case if my string is null show “â€, but there is a problem with
ContractNr. How can I test such a thing?
In the second the object is created but there is no value in it. I will test
that to see which value I want to show on screen. Ok StatusCd is null, so
there is no property Desc. I understand, but the I have to test always if
StatusCd is not null and then I have to test the Desc-property.
I think it is too much, I don’t see a good and short solution for that.
Try and Catch? But then the program will be full of try and catches.
Can some one point me out.
Thanks in advance
jac
public class Sessie : SessieBase
{
public Contract Contract;
public Sessie()
{
Contract Contract = new Contract ();
this.Contract = Contract;
}
}
public class ContractBase
{
private string mContractNr;
public string ContractNr
{
get
{
return mContractNr;
}
set
{
mContractNr = value;
}
}
private Status mStatusCd;
public Status StatusCd
{
get
{
return mStatusCd;
}
set
{
mStatusCd = value;
}
}
public ContractBase()
{
this.StatusCd = new Status();
}
}
public class Contract: ContractBase
{
}
Somewhere in the code I want to that :
this.TxtContractnr.Text = (this.Sessie.Contract.ContractNr == null ? "" :
this.Sessie.Contract.ContractNr.ToString());
this.TxtStatus.Text = (this.Sessie.Contract.StatusCd.Desc == null ? "" :
this.Sessie.Contract.StatusCd.Desc.ToString());
I receive : A first chance exception of type 'System.ArgumentNullException'
occurred in system.windows.forms.dll
Additional information: Value cannot be null.
But that is just the test I will do.
In first case if my string is null show “â€, but there is a problem with
ContractNr. How can I test such a thing?
In the second the object is created but there is no value in it. I will test
that to see which value I want to show on screen. Ok StatusCd is null, so
there is no property Desc. I understand, but the I have to test always if
StatusCd is not null and then I have to test the Desc-property.
I think it is too much, I don’t see a good and short solution for that.
Try and Catch? But then the program will be full of try and catches.
Can some one point me out.
Thanks in advance
jac