C#: strings and string literals
I have a solid impression that I should have known this from the previous life. What is a difference between these pieces of code?
string sql = "SELECT SUM(Quantity)
FROM Production.ProductInventory"
string sql = @"SELECT SUM(Quantity)
FROM Production.ProductInventory"
The first will result in a compiler error while the second one - the string literal, is completely legitimate! No more tedious and ugly concatenations. Remember moving SQL statements back and forth between SQL Server console and Visual Studio? Ew!
No comments:
Post a Comment