Giving the following examples:
string amountDisplay = presentation.Amount == 1 ? "" : String.Format("{0} x ", presentation.Amount);
is there anyway to use String.Format so it formats depending on properties without having to do a condition of the 'value' of the parameters ?
another use case:
String.Format("({0}) {1}-{2}", countryCode, areaCode, phonenumber);
if I only have phonenumber, I would end up with something like "() -5555555" which is not desirable.
another use case :
String.Format("my {0} has {1} cat[s]", "Aunt", 3)
in this case, I would like to include the s in the [] if the value > 1 for example.
Is there any black 'syntax' of String.Format that removes code parts depending on value of parameters or null ?
Thanks.