Advertisement
uniblab

Proper formatting for choice operator

Apr 25th, 2020
685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. // prototype
  2. var someValue = someCondition
  3.     ? trueValue
  4.     : falseValue
  5. ;
  6.  
  7.  
  8. // proper form in actual use
  9. public static System.String GetWebString( this System.Byte[] response, System.Text.Encoding encoding, System.String contentEncoding ) {
  10.     return ( contentEncoding.TrimToNull() ?? "identity" ).Equals( "identity", System.StringComparison.OrdinalIgnoreCase )
  11.         ? response.GetString( encoding )
  12.         : contentEncoding.Equals( "gzip", System.StringComparison.OrdinalIgnoreCase )
  13.             ? response.Gunzip( encoding )
  14.             : contentEncoding.Equals( "deflate", System.StringComparison.OrdinalIgnoreCase )
  15.                 ? response.Inflate( encoding )
  16.                 : throw new System.InvalidOperationException( System.String.Format(
  17.                     "Unknown Content-Encoding value received from server: {0}",
  18.                     contentEncoding
  19.                 ) )
  20.     ;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement