It's interesting to think about the "edge case" where the user creates an instance of the 'fileSize' object, supplying one valid int, and the other argument null: what's the right thing to do in that case ?
Should you throw an error in the constructor in that case ?
Here's some ideas:
public class fileSize
{
int? minSize;
int? maxSize;
public bool IsEmpty { get; set; }
public fileSize()
{
minSize = null;
maxSize = null;
IsEmpty = true;
}
public fileSize(int? MinSize, int? MaxSize)
{
minSize = MinSize;
maxSize = MaxSize;
IsEmpty = minSize == null || maxSize == null;
}
}
Tests:
fileSize f1 = new fileSize();
Console.WriteLine(f1.IsEmpty);
fileSize f2 = new fileSize(null,null);
Console.WriteLine(f2.IsEmpty);
fileSize f3 = new fileSize(100, 200);
Console.WriteLine(f3.IsEmpty);
fileSize f4 = new fileSize(100, null);
Console.WriteLine(f4.IsEmpty);