Bad form. Bad style. People will hate you. But, its totally legal.
I think I read this back in the language specification, or maybe a college professor said it, but I had forgotten about it until I read it on someone else’s blog.
namespace Test {
using System;
public class Test {
static void Foo(string @namespace) {
bool @true = @namespace == "hello";
if(@true) Console.WriteLine(@namespace);
}
}
[STAThread]
static void Main(string[] args) {
Test.Foo("hello"); // prints out "hello"
Test.Foo("world"); // prints nothing
}
}
C#Odd eh?
If you’re ever have a sudden urge to use a reserved word, and just *HAVE* to have the word “true” as a variable name, @true will work.
Now… if you ever use that in public, you may be bludgeoned to death by co-workers.
its called a “verbatim” identifier, and should only be used in tandem with a goto statement for maximum annoyance.