-1

So I was digging through some code and I saw something along these lines.

Func<T> @delegate = ...

My question is what is the @ operator used for in this case?

I've seen it used when creating string literals but never when referencing something other than a string.

DotNetRussell
  • 9,716
  • 10
  • 56
  • 111

1 Answers1

7

Func<T> is a generic delegate in C#.

delegate is a reserved word in C# so the developer prefixed it with @ to use it as a valid variable name.

You will see it in asp.net MVC project for HTML helpers where for setting class we use @class as class is a reserved word in C# so we can't have a variable with name class

Ehsan Sajjad
  • 61,834
  • 16
  • 105
  • 160