String interpolation - what does the @ sign inside the curly braces do?
Clash Royale CLAN TAG#URR8PPP
up vote
19
down vote
favorite
Consider:
string newline = "rn";
Console.WriteLine($"Hello without atnewlinehow are you?");
Console.WriteLine($"Hello with at@newlinehow are you?");
The output of both lines is identical. The newline is always printed as a newline.
Hello without at
how are you?
Hello with at
how are you?
So when do I need the at sign inside the curly braces?
c# .net
 |Â
show 2 more comments
up vote
19
down vote
favorite
Consider:
string newline = "rn";
Console.WriteLine($"Hello without atnewlinehow are you?");
Console.WriteLine($"Hello with at@newlinehow are you?");
The output of both lines is identical. The newline is always printed as a newline.
Hello without at
how are you?
Hello with at
how are you?
So when do I need the at sign inside the curly braces?
c# .net
1
Possible duplicate: stackoverflow.com/questions/6134547/…
– Keyur Ramoliya
Aug 31 at 8:59
5
This one is related
– Mong Zhu
Aug 31 at 9:00
7
@KeyurRamoliya: It's definitely not a duplicate of that. That's about verbatim string literals. This isn't one of those. It's using@
with an identifier, which is typically used with keywords, e.g.@this
as the name of the first parameter in an extension method.
– Jon Skeet
Aug 31 at 9:00
@KeyurRamoliya I don't think that's a correct duplicate. HimBromBeere's answer is correct.
– Sweeper
Aug 31 at 9:01
Reference for verbatim string here.
– Tetsuya Yamamoto
Aug 31 at 9:01
 |Â
show 2 more comments
up vote
19
down vote
favorite
up vote
19
down vote
favorite
Consider:
string newline = "rn";
Console.WriteLine($"Hello without atnewlinehow are you?");
Console.WriteLine($"Hello with at@newlinehow are you?");
The output of both lines is identical. The newline is always printed as a newline.
Hello without at
how are you?
Hello with at
how are you?
So when do I need the at sign inside the curly braces?
c# .net
Consider:
string newline = "rn";
Console.WriteLine($"Hello without atnewlinehow are you?");
Console.WriteLine($"Hello with at@newlinehow are you?");
The output of both lines is identical. The newline is always printed as a newline.
Hello without at
how are you?
Hello with at
how are you?
So when do I need the at sign inside the curly braces?
c# .net
edited Aug 31 at 13:52


Peter Mortensen
12.9k1983111
12.9k1983111
asked Aug 31 at 8:57
Thomas
1,0001833
1,0001833
1
Possible duplicate: stackoverflow.com/questions/6134547/…
– Keyur Ramoliya
Aug 31 at 8:59
5
This one is related
– Mong Zhu
Aug 31 at 9:00
7
@KeyurRamoliya: It's definitely not a duplicate of that. That's about verbatim string literals. This isn't one of those. It's using@
with an identifier, which is typically used with keywords, e.g.@this
as the name of the first parameter in an extension method.
– Jon Skeet
Aug 31 at 9:00
@KeyurRamoliya I don't think that's a correct duplicate. HimBromBeere's answer is correct.
– Sweeper
Aug 31 at 9:01
Reference for verbatim string here.
– Tetsuya Yamamoto
Aug 31 at 9:01
 |Â
show 2 more comments
1
Possible duplicate: stackoverflow.com/questions/6134547/…
– Keyur Ramoliya
Aug 31 at 8:59
5
This one is related
– Mong Zhu
Aug 31 at 9:00
7
@KeyurRamoliya: It's definitely not a duplicate of that. That's about verbatim string literals. This isn't one of those. It's using@
with an identifier, which is typically used with keywords, e.g.@this
as the name of the first parameter in an extension method.
– Jon Skeet
Aug 31 at 9:00
@KeyurRamoliya I don't think that's a correct duplicate. HimBromBeere's answer is correct.
– Sweeper
Aug 31 at 9:01
Reference for verbatim string here.
– Tetsuya Yamamoto
Aug 31 at 9:01
1
1
Possible duplicate: stackoverflow.com/questions/6134547/…
– Keyur Ramoliya
Aug 31 at 8:59
Possible duplicate: stackoverflow.com/questions/6134547/…
– Keyur Ramoliya
Aug 31 at 8:59
5
5
This one is related
– Mong Zhu
Aug 31 at 9:00
This one is related
– Mong Zhu
Aug 31 at 9:00
7
7
@KeyurRamoliya: It's definitely not a duplicate of that. That's about verbatim string literals. This isn't one of those. It's using
@
with an identifier, which is typically used with keywords, e.g. @this
as the name of the first parameter in an extension method.– Jon Skeet
Aug 31 at 9:00
@KeyurRamoliya: It's definitely not a duplicate of that. That's about verbatim string literals. This isn't one of those. It's using
@
with an identifier, which is typically used with keywords, e.g. @this
as the name of the first parameter in an extension method.– Jon Skeet
Aug 31 at 9:00
@KeyurRamoliya I don't think that's a correct duplicate. HimBromBeere's answer is correct.
– Sweeper
Aug 31 at 9:01
@KeyurRamoliya I don't think that's a correct duplicate. HimBromBeere's answer is correct.
– Sweeper
Aug 31 at 9:01
Reference for verbatim string here.
– Tetsuya Yamamoto
Aug 31 at 9:01
Reference for verbatim string here.
– Tetsuya Yamamoto
Aug 31 at 9:01
 |Â
show 2 more comments
2 Answers
2
active
oldest
votes
up vote
26
down vote
accepted
$"Hello myValue "
is an interpolated string which was introduced in C#6. In your case this is equivalent to a call to String.Format("Hello 0", myValue)
.
The verbatim (@
) is needed when your variable has the same name as a keyword, which, as far as I know, newline
is not. However the following would cause a compiler-error:
String.Format("Hello 0", if)
whilst this won´t:
String.Format("Hello 0", @if)
Here the verbatim tells the compiler that if
is the name of a variable, not the if
-keyword.
So you don´t need the verbatim in your case, because newline
is not a keyword. Or in other words your code is equivalent to this:
Console.WriteLine("Hello with at0how are you?", @newline);
which is a valid (even though redundant) use of the verbatim.
For further information refer to the documentation about string-interpolation.
1
$
is not really a shortcut forString.Format
it basically returns aFormattableString
which in many ways differs fromString.Format
– Mateusz
Aug 31 at 9:09
@Mateusz Doesn´tString.Format
return anFormatableString
also?
– HimBromBeere
Aug 31 at 9:10
Not quite the same,$
can return astring
already processed,FormattableString
which then can be used to process it on how you want/need it to andIFormattable
which is the only one that really relates toString.Format
method but it's not a shortcut, more like a long road to format.
– Mateusz
Aug 31 at 9:13
1
$"Hello myValue"
is in fact also a shortcut tostring.Format
since the compiler will only use theFormattableString
if the only target for the expression is aFormattableString
. So the compiler will reformat this directly to astring.Format
call.
– Lasse Vågsæther Karlsen
Aug 31 at 9:14
1
It is also worth to mention about interoperability between different languages. Keyword in one language is not necessarily the keyword in the second.
– Karol
Sep 1 at 12:11
 |Â
show 19 more comments
up vote
13
down vote
It's a redundant verbatim prefix. From the C# specification:
The prefix "@" enables the use of keywords as identifiers, which is useful when interfacing with other programming languages. The character @ is not actually part of the identifier, so the identifier might be seen in other languages as a normal identifier, without the prefix. An identifier with an @ prefix is called a verbatim identifier. Use of the @ prefix for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style.
A use case would be if you would want to write a function like this:
private void print(string @string) => Console.WriteLine(@string);
Normally you would not be able to name an identifier string
because it is a reserved keyword. The @
prefix enables you to do so.
4
Important part is "The character @ is not actually part of the identifier" because that explains why it compiles even if the variable doesn't have it.
– Tim Schmelter
Aug 31 at 9:08
4
Another part that I find important is "Use of the @ prefix for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style." So@newline
is tolerated but misleading/confusing.
– Jeppe Stig Nielsen
Aug 31 at 9:40
I note that your example does not match the text you've quoted from the specification, and that this is a very poor use case. The purpose of this feature is not to allow you to make a formal parameter called@string
because that would be a bizarre thing to do. The purpose of the feature is to allow you to, say, extend a third-party class written in a non-C# language that has a virtual member calledstring
. You need to be able to sayclass D : ThirdParty public override void @string() ...
. That would be a by-design use case.
– Eric Lippert
Aug 31 at 21:13
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
26
down vote
accepted
$"Hello myValue "
is an interpolated string which was introduced in C#6. In your case this is equivalent to a call to String.Format("Hello 0", myValue)
.
The verbatim (@
) is needed when your variable has the same name as a keyword, which, as far as I know, newline
is not. However the following would cause a compiler-error:
String.Format("Hello 0", if)
whilst this won´t:
String.Format("Hello 0", @if)
Here the verbatim tells the compiler that if
is the name of a variable, not the if
-keyword.
So you don´t need the verbatim in your case, because newline
is not a keyword. Or in other words your code is equivalent to this:
Console.WriteLine("Hello with at0how are you?", @newline);
which is a valid (even though redundant) use of the verbatim.
For further information refer to the documentation about string-interpolation.
1
$
is not really a shortcut forString.Format
it basically returns aFormattableString
which in many ways differs fromString.Format
– Mateusz
Aug 31 at 9:09
@Mateusz Doesn´tString.Format
return anFormatableString
also?
– HimBromBeere
Aug 31 at 9:10
Not quite the same,$
can return astring
already processed,FormattableString
which then can be used to process it on how you want/need it to andIFormattable
which is the only one that really relates toString.Format
method but it's not a shortcut, more like a long road to format.
– Mateusz
Aug 31 at 9:13
1
$"Hello myValue"
is in fact also a shortcut tostring.Format
since the compiler will only use theFormattableString
if the only target for the expression is aFormattableString
. So the compiler will reformat this directly to astring.Format
call.
– Lasse Vågsæther Karlsen
Aug 31 at 9:14
1
It is also worth to mention about interoperability between different languages. Keyword in one language is not necessarily the keyword in the second.
– Karol
Sep 1 at 12:11
 |Â
show 19 more comments
up vote
26
down vote
accepted
$"Hello myValue "
is an interpolated string which was introduced in C#6. In your case this is equivalent to a call to String.Format("Hello 0", myValue)
.
The verbatim (@
) is needed when your variable has the same name as a keyword, which, as far as I know, newline
is not. However the following would cause a compiler-error:
String.Format("Hello 0", if)
whilst this won´t:
String.Format("Hello 0", @if)
Here the verbatim tells the compiler that if
is the name of a variable, not the if
-keyword.
So you don´t need the verbatim in your case, because newline
is not a keyword. Or in other words your code is equivalent to this:
Console.WriteLine("Hello with at0how are you?", @newline);
which is a valid (even though redundant) use of the verbatim.
For further information refer to the documentation about string-interpolation.
1
$
is not really a shortcut forString.Format
it basically returns aFormattableString
which in many ways differs fromString.Format
– Mateusz
Aug 31 at 9:09
@Mateusz Doesn´tString.Format
return anFormatableString
also?
– HimBromBeere
Aug 31 at 9:10
Not quite the same,$
can return astring
already processed,FormattableString
which then can be used to process it on how you want/need it to andIFormattable
which is the only one that really relates toString.Format
method but it's not a shortcut, more like a long road to format.
– Mateusz
Aug 31 at 9:13
1
$"Hello myValue"
is in fact also a shortcut tostring.Format
since the compiler will only use theFormattableString
if the only target for the expression is aFormattableString
. So the compiler will reformat this directly to astring.Format
call.
– Lasse Vågsæther Karlsen
Aug 31 at 9:14
1
It is also worth to mention about interoperability between different languages. Keyword in one language is not necessarily the keyword in the second.
– Karol
Sep 1 at 12:11
 |Â
show 19 more comments
up vote
26
down vote
accepted
up vote
26
down vote
accepted
$"Hello myValue "
is an interpolated string which was introduced in C#6. In your case this is equivalent to a call to String.Format("Hello 0", myValue)
.
The verbatim (@
) is needed when your variable has the same name as a keyword, which, as far as I know, newline
is not. However the following would cause a compiler-error:
String.Format("Hello 0", if)
whilst this won´t:
String.Format("Hello 0", @if)
Here the verbatim tells the compiler that if
is the name of a variable, not the if
-keyword.
So you don´t need the verbatim in your case, because newline
is not a keyword. Or in other words your code is equivalent to this:
Console.WriteLine("Hello with at0how are you?", @newline);
which is a valid (even though redundant) use of the verbatim.
For further information refer to the documentation about string-interpolation.
$"Hello myValue "
is an interpolated string which was introduced in C#6. In your case this is equivalent to a call to String.Format("Hello 0", myValue)
.
The verbatim (@
) is needed when your variable has the same name as a keyword, which, as far as I know, newline
is not. However the following would cause a compiler-error:
String.Format("Hello 0", if)
whilst this won´t:
String.Format("Hello 0", @if)
Here the verbatim tells the compiler that if
is the name of a variable, not the if
-keyword.
So you don´t need the verbatim in your case, because newline
is not a keyword. Or in other words your code is equivalent to this:
Console.WriteLine("Hello with at0how are you?", @newline);
which is a valid (even though redundant) use of the verbatim.
For further information refer to the documentation about string-interpolation.
edited Sep 4 at 6:41
answered Aug 31 at 8:59
HimBromBeere
21.7k33156
21.7k33156
1
$
is not really a shortcut forString.Format
it basically returns aFormattableString
which in many ways differs fromString.Format
– Mateusz
Aug 31 at 9:09
@Mateusz Doesn´tString.Format
return anFormatableString
also?
– HimBromBeere
Aug 31 at 9:10
Not quite the same,$
can return astring
already processed,FormattableString
which then can be used to process it on how you want/need it to andIFormattable
which is the only one that really relates toString.Format
method but it's not a shortcut, more like a long road to format.
– Mateusz
Aug 31 at 9:13
1
$"Hello myValue"
is in fact also a shortcut tostring.Format
since the compiler will only use theFormattableString
if the only target for the expression is aFormattableString
. So the compiler will reformat this directly to astring.Format
call.
– Lasse Vågsæther Karlsen
Aug 31 at 9:14
1
It is also worth to mention about interoperability between different languages. Keyword in one language is not necessarily the keyword in the second.
– Karol
Sep 1 at 12:11
 |Â
show 19 more comments
1
$
is not really a shortcut forString.Format
it basically returns aFormattableString
which in many ways differs fromString.Format
– Mateusz
Aug 31 at 9:09
@Mateusz Doesn´tString.Format
return anFormatableString
also?
– HimBromBeere
Aug 31 at 9:10
Not quite the same,$
can return astring
already processed,FormattableString
which then can be used to process it on how you want/need it to andIFormattable
which is the only one that really relates toString.Format
method but it's not a shortcut, more like a long road to format.
– Mateusz
Aug 31 at 9:13
1
$"Hello myValue"
is in fact also a shortcut tostring.Format
since the compiler will only use theFormattableString
if the only target for the expression is aFormattableString
. So the compiler will reformat this directly to astring.Format
call.
– Lasse Vågsæther Karlsen
Aug 31 at 9:14
1
It is also worth to mention about interoperability between different languages. Keyword in one language is not necessarily the keyword in the second.
– Karol
Sep 1 at 12:11
1
1
$
is not really a shortcut for String.Format
it basically returns a FormattableString
which in many ways differs from String.Format
– Mateusz
Aug 31 at 9:09
$
is not really a shortcut for String.Format
it basically returns a FormattableString
which in many ways differs from String.Format
– Mateusz
Aug 31 at 9:09
@Mateusz Doesn´t
String.Format
return an FormatableString
also?– HimBromBeere
Aug 31 at 9:10
@Mateusz Doesn´t
String.Format
return an FormatableString
also?– HimBromBeere
Aug 31 at 9:10
Not quite the same,
$
can return a string
already processed, FormattableString
which then can be used to process it on how you want/need it to and IFormattable
which is the only one that really relates to String.Format
method but it's not a shortcut, more like a long road to format.– Mateusz
Aug 31 at 9:13
Not quite the same,
$
can return a string
already processed, FormattableString
which then can be used to process it on how you want/need it to and IFormattable
which is the only one that really relates to String.Format
method but it's not a shortcut, more like a long road to format.– Mateusz
Aug 31 at 9:13
1
1
$"Hello myValue"
is in fact also a shortcut to string.Format
since the compiler will only use the FormattableString
if the only target for the expression is a FormattableString
. So the compiler will reformat this directly to a string.Format
call.– Lasse Vågsæther Karlsen
Aug 31 at 9:14
$"Hello myValue"
is in fact also a shortcut to string.Format
since the compiler will only use the FormattableString
if the only target for the expression is a FormattableString
. So the compiler will reformat this directly to a string.Format
call.– Lasse Vågsæther Karlsen
Aug 31 at 9:14
1
1
It is also worth to mention about interoperability between different languages. Keyword in one language is not necessarily the keyword in the second.
– Karol
Sep 1 at 12:11
It is also worth to mention about interoperability between different languages. Keyword in one language is not necessarily the keyword in the second.
– Karol
Sep 1 at 12:11
 |Â
show 19 more comments
up vote
13
down vote
It's a redundant verbatim prefix. From the C# specification:
The prefix "@" enables the use of keywords as identifiers, which is useful when interfacing with other programming languages. The character @ is not actually part of the identifier, so the identifier might be seen in other languages as a normal identifier, without the prefix. An identifier with an @ prefix is called a verbatim identifier. Use of the @ prefix for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style.
A use case would be if you would want to write a function like this:
private void print(string @string) => Console.WriteLine(@string);
Normally you would not be able to name an identifier string
because it is a reserved keyword. The @
prefix enables you to do so.
4
Important part is "The character @ is not actually part of the identifier" because that explains why it compiles even if the variable doesn't have it.
– Tim Schmelter
Aug 31 at 9:08
4
Another part that I find important is "Use of the @ prefix for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style." So@newline
is tolerated but misleading/confusing.
– Jeppe Stig Nielsen
Aug 31 at 9:40
I note that your example does not match the text you've quoted from the specification, and that this is a very poor use case. The purpose of this feature is not to allow you to make a formal parameter called@string
because that would be a bizarre thing to do. The purpose of the feature is to allow you to, say, extend a third-party class written in a non-C# language that has a virtual member calledstring
. You need to be able to sayclass D : ThirdParty public override void @string() ...
. That would be a by-design use case.
– Eric Lippert
Aug 31 at 21:13
add a comment |Â
up vote
13
down vote
It's a redundant verbatim prefix. From the C# specification:
The prefix "@" enables the use of keywords as identifiers, which is useful when interfacing with other programming languages. The character @ is not actually part of the identifier, so the identifier might be seen in other languages as a normal identifier, without the prefix. An identifier with an @ prefix is called a verbatim identifier. Use of the @ prefix for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style.
A use case would be if you would want to write a function like this:
private void print(string @string) => Console.WriteLine(@string);
Normally you would not be able to name an identifier string
because it is a reserved keyword. The @
prefix enables you to do so.
4
Important part is "The character @ is not actually part of the identifier" because that explains why it compiles even if the variable doesn't have it.
– Tim Schmelter
Aug 31 at 9:08
4
Another part that I find important is "Use of the @ prefix for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style." So@newline
is tolerated but misleading/confusing.
– Jeppe Stig Nielsen
Aug 31 at 9:40
I note that your example does not match the text you've quoted from the specification, and that this is a very poor use case. The purpose of this feature is not to allow you to make a formal parameter called@string
because that would be a bizarre thing to do. The purpose of the feature is to allow you to, say, extend a third-party class written in a non-C# language that has a virtual member calledstring
. You need to be able to sayclass D : ThirdParty public override void @string() ...
. That would be a by-design use case.
– Eric Lippert
Aug 31 at 21:13
add a comment |Â
up vote
13
down vote
up vote
13
down vote
It's a redundant verbatim prefix. From the C# specification:
The prefix "@" enables the use of keywords as identifiers, which is useful when interfacing with other programming languages. The character @ is not actually part of the identifier, so the identifier might be seen in other languages as a normal identifier, without the prefix. An identifier with an @ prefix is called a verbatim identifier. Use of the @ prefix for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style.
A use case would be if you would want to write a function like this:
private void print(string @string) => Console.WriteLine(@string);
Normally you would not be able to name an identifier string
because it is a reserved keyword. The @
prefix enables you to do so.
It's a redundant verbatim prefix. From the C# specification:
The prefix "@" enables the use of keywords as identifiers, which is useful when interfacing with other programming languages. The character @ is not actually part of the identifier, so the identifier might be seen in other languages as a normal identifier, without the prefix. An identifier with an @ prefix is called a verbatim identifier. Use of the @ prefix for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style.
A use case would be if you would want to write a function like this:
private void print(string @string) => Console.WriteLine(@string);
Normally you would not be able to name an identifier string
because it is a reserved keyword. The @
prefix enables you to do so.
edited Aug 31 at 13:54


Peter Mortensen
12.9k1983111
12.9k1983111
answered Aug 31 at 9:01
ChristianMurschall
907315
907315
4
Important part is "The character @ is not actually part of the identifier" because that explains why it compiles even if the variable doesn't have it.
– Tim Schmelter
Aug 31 at 9:08
4
Another part that I find important is "Use of the @ prefix for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style." So@newline
is tolerated but misleading/confusing.
– Jeppe Stig Nielsen
Aug 31 at 9:40
I note that your example does not match the text you've quoted from the specification, and that this is a very poor use case. The purpose of this feature is not to allow you to make a formal parameter called@string
because that would be a bizarre thing to do. The purpose of the feature is to allow you to, say, extend a third-party class written in a non-C# language that has a virtual member calledstring
. You need to be able to sayclass D : ThirdParty public override void @string() ...
. That would be a by-design use case.
– Eric Lippert
Aug 31 at 21:13
add a comment |Â
4
Important part is "The character @ is not actually part of the identifier" because that explains why it compiles even if the variable doesn't have it.
– Tim Schmelter
Aug 31 at 9:08
4
Another part that I find important is "Use of the @ prefix for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style." So@newline
is tolerated but misleading/confusing.
– Jeppe Stig Nielsen
Aug 31 at 9:40
I note that your example does not match the text you've quoted from the specification, and that this is a very poor use case. The purpose of this feature is not to allow you to make a formal parameter called@string
because that would be a bizarre thing to do. The purpose of the feature is to allow you to, say, extend a third-party class written in a non-C# language that has a virtual member calledstring
. You need to be able to sayclass D : ThirdParty public override void @string() ...
. That would be a by-design use case.
– Eric Lippert
Aug 31 at 21:13
4
4
Important part is "The character @ is not actually part of the identifier" because that explains why it compiles even if the variable doesn't have it.
– Tim Schmelter
Aug 31 at 9:08
Important part is "The character @ is not actually part of the identifier" because that explains why it compiles even if the variable doesn't have it.
– Tim Schmelter
Aug 31 at 9:08
4
4
Another part that I find important is "Use of the @ prefix for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style." So
@newline
is tolerated but misleading/confusing.– Jeppe Stig Nielsen
Aug 31 at 9:40
Another part that I find important is "Use of the @ prefix for identifiers that are not keywords is permitted, but strongly discouraged as a matter of style." So
@newline
is tolerated but misleading/confusing.– Jeppe Stig Nielsen
Aug 31 at 9:40
I note that your example does not match the text you've quoted from the specification, and that this is a very poor use case. The purpose of this feature is not to allow you to make a formal parameter called
@string
because that would be a bizarre thing to do. The purpose of the feature is to allow you to, say, extend a third-party class written in a non-C# language that has a virtual member called string
. You need to be able to say class D : ThirdParty public override void @string() ...
. That would be a by-design use case.– Eric Lippert
Aug 31 at 21:13
I note that your example does not match the text you've quoted from the specification, and that this is a very poor use case. The purpose of this feature is not to allow you to make a formal parameter called
@string
because that would be a bizarre thing to do. The purpose of the feature is to allow you to, say, extend a third-party class written in a non-C# language that has a virtual member called string
. You need to be able to say class D : ThirdParty public override void @string() ...
. That would be a by-design use case.– Eric Lippert
Aug 31 at 21:13
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52111891%2fstring-interpolation-what-does-the-sign-inside-the-curly-braces-do%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Possible duplicate: stackoverflow.com/questions/6134547/…
– Keyur Ramoliya
Aug 31 at 8:59
5
This one is related
– Mong Zhu
Aug 31 at 9:00
7
@KeyurRamoliya: It's definitely not a duplicate of that. That's about verbatim string literals. This isn't one of those. It's using
@
with an identifier, which is typically used with keywords, e.g.@this
as the name of the first parameter in an extension method.– Jon Skeet
Aug 31 at 9:00
@KeyurRamoliya I don't think that's a correct duplicate. HimBromBeere's answer is correct.
– Sweeper
Aug 31 at 9:01
Reference for verbatim string here.
– Tetsuya Yamamoto
Aug 31 at 9:01