When the expression is too long and cannot fit into the display area or for the accuracy of the source code, we will write a long expression in multi-line. I tried to check the related programming rules, but I can not find some related to the character , which should be placed at the end of the line or first of the next line.
For example, an expression of a long IF in C # code,
if (!double.TryParse(text4Hours.Text, out outputValue)||
!double.TryParse(text4Hours.Text, out outputValue)||
!double.TryParse(text10Hours.Text, out outputValue)){ }
OR
if (!double.TryParse(text4Hours.Text, out outputValue)
||!double.TryParse(text4Hours.Text, out outputValue)
||!double.TryParse(text10Hours.Text, out outputValue)){ }
Parallel symbol || can be put at the end of the line or in the first line of the next line, any rules declare that we should follow the first or second? What are the benefits for this?
Another example is
answer = amount4Hours * double.Parse(text4Hours.Text) +
amount8Hours * double.Parse(text8Hours.Text) -
break45 * double.Parse(text8Hours.Text) +
amount10Hours * double.Parse(text10Hours.Text) -
break45 * double.Parse(text10Hours.Text);
OR
answer = amount4Hours * double.Parse(text4Hours.Text)
+amount8Hours * double.Parse(text8Hours.Text)
-break45 * double.Parse(text8Hours.Text)
+amount10Hours * double.Parse(text10Hours.Text)
-break45 * double.Parse(text10Hours.Text);
I know that we should try to avoid a long expression, but if you consider that the display area of a text editor is small or other problems, then this question will pop up anyway. Thank.
V-shy source
share