uniblab

How to format super-long parameter list

Mar 30th, 2021 (edited)
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. // correct
  2. // there are no parameters
  3. void someFunction() {
  4.   // code here
  5. }
  6.  
  7. // correct
  8. // the parameters comfortably in one line of even narrow viewports
  9. void someFunction( int foo ) {
  10.  // code here
  11. }
  12.  
  13. // WRONG
  14. // the function declaration and parameters extend off the screen even on big viewports
  15. public static System.Collections.Generic.IEnumerable<System.String> ReadRecord( this System.IO.TextReader file, System.String recordSeparator, System.Char quoteChar, System.Char fieldSeparator ) {
  16.     // code here
  17. }
  18.  
  19. // CORRECT!
  20. // the function declaration is broken over multiple lines, EACH of which fit comfortably
  21. public static System.Collections.Generic.IEnumerable<System.String> ReadRecord(
  22.     this System.IO.TextReader file, System.String recordSeparator,
  23.     System.Char quoteChar, System.Char fieldSeparator
  24. ) {
  25.     // code here
  26. }
Add Comment
Please, Sign In to add comment