I have a string errMsg to be printed after an input file is read. After the validations are done, if success==false it calls the method PrintErrorMessage(string)
//Validations
//First Validation: checks the value of input string realization.
success = Numerical.Check("Realizations", inputs.realizations.ToString(), out ltester, out errMsg);
sb.AppendLine(errMsg);
//Second Validation: checks the value of the input string diameter.
success = Numerical.Check("Pipe Outside Diameter", inputs.pipeOD.ToString(), out dtester, out errMsg);
sb.AppendLine(errMsg);
if (!success)
{
PrintErrorMessage(success, errTitle, sb.ToString());
}
Here's the method where I print the error:
Streamwriter swpt = new Streamwriter(....);
private void PrintErrorMessage(bool success, string errTitle, string errMsg)
{
if (!success)
{
swRpt.WriteLine(errTitle + errMsg);
}
}
The question is this: Instead of appending the StringBuilder at each and every step after each validation, can I use a ref type and pass it in the PrintErrorMessage function and append it there?
Instead of appending the stringbuilder at each an everystep after each validation, can I use a ref type and pass it in the PrintErrorMessage function and append it there
You can pass it without ref and append to it. StringBuilder is a Reference Type
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With