uniblab icon

How to format super-long parameter list

uniblab | PRO | 03/30/21 11:51:21 PM UTC (Edited) | 0 ⭐ | 1374 👁️ | Never ⏰ | []
C# |

840 B

|

None

|

0 👍

/

0 👎

// correct
// there are no parameters
void someFunction() {
  // code here
}
 
// correct
// the parameters comfortably in one line of even narrow viewports
void someFunction( int foo ) {
 // code here
}
 
// WRONG
// the function declaration and parameters extend off the screen even on big viewports
public static System.Collections.Generic.IEnumerable<System.String> ReadRecord( this System.IO.TextReader file, System.String recordSeparator, System.Char quoteChar, System.Char fieldSeparator ) {
    // code here
}
 
// CORRECT!
// the function declaration is broken over multiple lines, EACH of which fit comfortably
public static System.Collections.Generic.IEnumerable<System.String> ReadRecord( 
    this System.IO.TextReader file, System.String recordSeparator, 
    System.Char quoteChar, System.Char fieldSeparator 
) {
    // code here
}

Comments