Monday, 28 May 2012

use of @ symbol in c#


The @ symbol serves 2 purposes in C#:
The first is that it allows you to use a reserved keyowrd as a variable like this:
int @int = 15;
The second option lets you specify a string without having to excape any characters. For instance the '\' character is an escape character so typically you would need to do this:
var myString = "c:\\myfolder\\myfile.txt"
alternatively you can do this:
var myString = @"c:\myFolder\myfile.txt"

No comments:

Post a Comment