M
Mark Rae
Hi,
I posted a couple of days ago about the possibility of "simulating" in
..NET1.1 the nullable datatypes available in .NET2.0 - I'm nearly there, but
require a bit more guidance.
Basically, I have a class file which contains the various class definitions,
as follows:
using System;
namespace shared
{
public class NullableDateTime
{
private DateTime pdtmValue;
public NullableDateTime(DateTime dtmValue) {this.pdtmValue =
dtmValue;}
public DateTime value {get{return this.pdtmValue;}}
public bool HasValue {get{return this != null;}}
};
}
Then I have another class file with a NullableDateTime property, as follows:
using shared;
using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
namespace DataFeeds
{
public class CTransaction
{
private NullableDateTime pTradeDate;
public NullableDateTime TradeDate
{
get {return pTradeDate;}
set {pTradeDate = value;}
}
}
}
Finally, I create an instance of the CTransactions class, as follows:
CTransaction objTransaction = new CTransaction();
However, unless I explicitly populate objTransaction.TradeDate, it is
undefined.
I want objTransaction.TradeDate to be populated with a null value by default
and its HasValue property to return false unless I explicitly populate it,
in which case I want its HasValue property to return true, otherwise I may
as well not bother...
Any assistance gratefully received.
Mark
I posted a couple of days ago about the possibility of "simulating" in
..NET1.1 the nullable datatypes available in .NET2.0 - I'm nearly there, but
require a bit more guidance.
Basically, I have a class file which contains the various class definitions,
as follows:
using System;
namespace shared
{
public class NullableDateTime
{
private DateTime pdtmValue;
public NullableDateTime(DateTime dtmValue) {this.pdtmValue =
dtmValue;}
public DateTime value {get{return this.pdtmValue;}}
public bool HasValue {get{return this != null;}}
};
}
Then I have another class file with a NullableDateTime property, as follows:
using shared;
using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
namespace DataFeeds
{
public class CTransaction
{
private NullableDateTime pTradeDate;
public NullableDateTime TradeDate
{
get {return pTradeDate;}
set {pTradeDate = value;}
}
}
}
Finally, I create an instance of the CTransactions class, as follows:
CTransaction objTransaction = new CTransaction();
However, unless I explicitly populate objTransaction.TradeDate, it is
undefined.
I want objTransaction.TradeDate to be populated with a null value by default
and its HasValue property to return false unless I explicitly populate it,
in which case I want its HasValue property to return true, otherwise I may
as well not bother...
Any assistance gratefully received.
Mark