Thursday, October 23, 2014

C# abstract classes and methods in aggregation situations - how?

The implementation of the class must have the same parameters:



public class AggregateClass : BaseAggregateClass
{
private ComponentClass m_attribute;
private bool m_valid;

public override bool Valid
{
get
{
return m_valid;
}
}

public override bool Check()
{
checkVal(m_attribute);
return m_valid;
}

public override void checkVal(BaseComponentClass attrib)
{
if (attrib.Value == null)
m_valid = false;
}
}

You will then get a warning as you a testing an int for null which will always be false.

No comments:

Post a Comment