[Solved] Convert if condition into ternary with C#

If you have multiple fields to check, simply make a small helper method that returns a string (or empty) based on a condition (boolean): messageErreur += Check(!myField.IsNullOrNa(), myField.IsDecimalWithMessage(nameof(myField)); messageErreur += Check(myField.HasError(), myField.HasError(nameof(myField)); private string Check(bool condition, string message) => condition ? message : string.Empty; 0 solved Convert if condition into ternary with C#