In the response code this question in SOen I found an unfamiliar statement line in C #. I tested this line and it works, but I did not understand the meaning of this @
character behind the member name.
// declara "@foo" como uma string com o valor "bar"
var @foo = "bar";
// declara "@abc" como um tipo anônimo com sub valores
var @abc = new {a = 32, b = 64, c = 128}
And I also noticed that it works with classes and types:
class @Program {
void @Main (string[] args) {
...
But by passing the name over the names, Visual Studio's IntelliSense removes @ from names:
And I can also call members with or without @
:
void @Foo () {
Bar();
@Bar();
}
void @Bar() {
...
}
And even if @bar
does not have @
, it can be called with it in the same way.
And I can also declare a method called void
:
void @void () { ... }
I know that in Visual Basic, you can declare members with names already reserved by the language using [...] in the names. This is the same thing, only in C #? Or do you have another role besides that?