code_junkie

Using a Boolean Expression in a StringBuilder

Nov 13th, 2011
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. string someText = (dbInfo.IsIdentity) ? "First Option" : "Second Option";
  2.  
  3. script.Append("sometext" + (dbInfo.IsIdentity) ? " IDENTITY(1,1)" : "");
  4.  
  5. script.Append("sometext" + ((dbInfo.IsIdentity) ? " IDENTITY(1,1)" : ""));
  6.  
  7. script.Append( "sometext" );
  8. script.Append( dbInfo.IsIdentity ? " IDENTITY(1,1)" : "" );
  9.  
  10. script.AppendFormat("sometext{0}", dbInfo.IsIdentity ? " IDENTITY(1,1)" : "");
  11.  
  12. script.Append("sometext");
  13. script.Append(dbInfo.IsIdentity ? " IDENTITY(1,1)" : "");
  14.  
  15. script.Append("sometext");
  16. if(dbInfo.IsIdentity) script.Append(" IDENTITY(1,1)");
  17.  
  18. script.Append("sometext" + ((dbInfo.IsIdentity) ? " IDENTITY(1,1)" : ""));
Add Comment
Please, Sign In to add comment