Mixing string verbatim (@) and string interpolation ($) characters

By | 2019-08-29

It is possible to combine the string verbatim (@) and string interpolation ($) characters when entering string literals in your C# code. In order to do that you must first use the $ character followed by @ character.
Example:

int id = 1;
var result = await _con.QueryAsync(
                $@"select *
                    from   A
                    where A.ID = {id}");

Leave a Reply

Your email address will not be published. Required fields are marked *