A real newbie question

  • Thread starter Thread starter Danny Ni
  • Start date Start date
D

Danny Ni

Hi,

The following statement in C#:
FileInfo f = new FileInfo(@"C:\Test.txt");

What does @ mean?

Thanks in Advance
 
Hi Danny Ni,

The @ means "Ignore escape characters!" in the following string.
In your sample, these two lines are equal:

FileInfo f = new FileInfo(@"C:\Test.txt");
FileInfo f = new FileInfo("C:\\Test.txt");

Happy coding!
Morten
 
Danny Ni said:
The following statement in C#:
FileInfo f = new FileInfo(@"C:\Test.txt");

What does @ mean?

It means it's a verbatim literal string - any backslashes (and
newlines) in the string aren't treated as escape characters or real
line terminators. It means that for the above, you can write it as is
instead of

"C:\\Test.txt"
 
Back
Top