3

Possible Duplicate:
What does placing a @ in front of a C# variable name do?

I am trying to learn C# lambda expressions. As I search for examples I am seeing the below code

Where(@t => string.Compare(@t.Code, argument.Code, StringComparison.CurrentCultureIgnoreCase) == 0)

I am wondering what does the '@' symbole before the t mean?

Community
  • 1
  • 1
Srijit
  • 475
  • 7
  • 30
  • 2
    same as here http://stackoverflow.com/questions/254669/what-does-placing-a-in-front-of-a-c-sharp-variable-name-do : its just a way to name variables. – Philipp Aumayr Jan 26 '13 at 21:17
  • 2
    In other words - not needed and confusing, in this case. – Oded Jan 26 '13 at 21:18
  • It's an odd choice though, because as far as I know, 't' isn't a keyword in any context... – Tharwen Jan 26 '13 at 21:18
  • @Tharwen - It seems Resharper does that sometimes http://stackoverflow.com/questions/9304544/resharper-gives-an-prefix-to-a-variable-name-in-a-lambda-expression – keyboardP Jan 26 '13 at 21:19
  • It's just a way to allow declaring reserved keywords as vars. void Foo(int @string) – Parimal Raj Jan 26 '13 at 21:27

1 Answers1

5

Nothing unusual. You can prefix varible names with @ as a sort of escape if the varible is a key word.

For example you can also do 'var @class = 5' . Normally you'd not be able to compile as class is a keyword, but prefixing with @ allows you to use it as a varible.

Andy
  • 8,432
  • 6
  • 38
  • 76