D
dvestal
I have a class with public members, and I need to know whether those
members have been explicitly initialized. I could accomplish that
with a class like this:
class C
{
private bool m_isSet = false;
private object m_object;
public object MyObj
{
get
{
return m_object;
}
set
{
m_object = value;
m_isSet = true;
}
}
}
....but for my purposes, that's way too verbose. I need a way to
achieve that functionality, but write the class much more concisely.
Does anybody know a way to do this while allowing a shorter class
definition, such as the one below?
class C
{
// Is there any way to know when
// MyObj is set?
public object MyObj;
}
members have been explicitly initialized. I could accomplish that
with a class like this:
class C
{
private bool m_isSet = false;
private object m_object;
public object MyObj
{
get
{
return m_object;
}
set
{
m_object = value;
m_isSet = true;
}
}
}
....but for my purposes, that's way too verbose. I need a way to
achieve that functionality, but write the class much more concisely.
Does anybody know a way to do this while allowing a shorter class
definition, such as the one below?
class C
{
// Is there any way to know when
// MyObj is set?
public object MyObj;
}