Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# prefixing parameter names with @ [duplicate]

Tags:

c#

Possible Duplicate:
What does the @ symbol before a variable name mean in C#?

Duplicate:

What does the @ symbol before a variable name mean in C#?

Sometimes I see some C# code where a method-parameter is prefixed with an @, like this:

public static void SomeStaticMethod( SomeType @parameterName ) { } 

What is the meaning of this ? Does it has some significant special meaning ?

I am creating an EventListener in NHibernate, and when I let VS.NET generate the interface methods, it generates the OnPostLoad method like this:

public class PostLoadEventListener : IPostLoadEventListener {     public void OnPostLoad( PostLoadEvent @event )     {      } } 

Why is this ?

like image 352
Frederik Gheysels Avatar asked Jun 24 '09 14:06

Frederik Gheysels


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is C full form?

Full form of C is “COMPILE”.

Is C language easy?

C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.

What are the basics of C?

C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.


1 Answers

Try and make a variable named class and see what happens -- You'll notice you get an error.

This lets you used reserved words as variable names.

Unrelated, you'll also notice strings prefixed with @ as well -- This isn't the same thing...

string says = @"He said ""This literal string lets me use \ normally      and even line breaks""."; 

This allows you to use 'literal' value of the string, meaning you can have new lines or characters without escapes, etc...

like image 179
hugoware Avatar answered Oct 17 '22 12:10

hugoware