#962 – Statements Can Span Multiple Lines
October 29, 2013 Leave a comment
Single statements in C# (as opposed to a block of statements enclosed in curly braces) are typically written on a single line and terminated by a semicolon.
The code fragment below contains two statements, one that initializes an instance of a Dog and one that invokes the Bark method on that instance. Each of the statements is terminated by a semicolon.
Dog d1 = new Dog("Jack", 17); d1.Bark("Yip", 4);
You can break a statement into as many lines as you like in your source code, as long as you don’t insert a line break in the middle of an identifier. The code fragment below splits the two statements above into several lines.
Dog d1 = new Dog( "Jack", // Name 17); // Age d1.Bark( "Yip", // Bark sound 4); // # times to bark