if (record["Dosage"].ToString() != string.Empty)
result.StartsWith("/") && result.EndsWith("/") ? result.Replace("/", string.Empty) : result;
The second line there is not a statement, it is an expression. Not all expressions can be statements in C#, so this is a syntax error.
Presumably you meant to assign the result of this to result
:
if (record["Dosage"].ToString() != string.Empty)
result = (result.StartsWith("/") && result.EndsWith("/")) ? result.Replace("/", string.Empty) : result;
Further, you should consider enclosing the bodies of if
/ else
blocks with braces ({}
). Without braces, the way in which these blocks nest is not intuitive, and it will hamper future maintenance. (For example, can you tell which if
block the else if
block will belong to? Will the next person who inherits this project be able to not only tell the difference, but understand what nesting was intended? Make it explicit!)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…