Skip to content
Discussion options

You must be logged in to vote

Those are already literals/constants, though. Why do you need a different syntax?

These produce identical IL byte code:

public void M1() {
    const string sql = "SELECT COUNT(1) AS Value FROM MyTable";
    Test(sql);
}

public void M2() {
    Test($"SELECT COUNT(1) AS Value FROM {nameof(DbContext.MyTable)}");
}

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@HaloFour
Comment options

@danatcofo
Comment options

@HaloFour
Comment options

Answer selected by danatcofo
@danatcofo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants