I have the following struct
:
public struct VolumeIssue
{
public readonly string Volume;
public readonly string Issue;
public VolumeIssue(string volume, string issue)
{
this.Volume = volume;
this.Issue = issue;
}
public bool IsNullOrWhiteSpace()
{
return string.IsNullOrWhiteSpace(this.Volume) && string.IsNullOrWhiteSpace(this.Issue);
}
public override string ToString()
{
StringBuilder stringRep = new StringBuilder("");
if (!string.IsNullOrWhiteSpace(this.Volume))
{
stringRep.AppendFormat("v. {0}", this.Volume);
if (!string.IsNullOrWhiteSpace(this.Issue))
{
stringRep.AppendFormat(" iss. {0}", this.Issue);
}
}
return stringRep.ToString();
}
}
Overall I am happy with it. But being still a relatively inexperienced developer, I would like some input on the design of this struct
. Ideas on how to flesh it out are also greatly appreciated.
In order to add more context, here is one of the use cases:
public class IssueRangeCoverage
{
public VolumeIssue Start { get; set; }
public VolumeIssue End { get; set; }
public override string ToString()
{
if (this.Start.IsNullOrWhiteSpace() && this.End.IsNullOrWhiteSpace())
{
return "";
}
string endString = this.End.ToString();
if (string.IsNullOrWhiteSpace(endString))
{
endString = "Current";
}
return this.Start.ToString() + " - " + endString;
}
}