Verbatim Literal is a string with an @ symbol prefix, as in @“Hello”. Verbatim literals make escape sequences translate as normal printable characters to enhance readability.
Practical Example:
Without Verbatim Literal : "C:\\Pragim\\DotNet\\Training\\Csharp"; // Less Readable
C# example program used in the demo
using System;
namespace ConsoleApplication1
{
class Program
{
public static void Main()
{
// Displaying double quotes in c#
string Name = "\"Pragim\"";
Console.WriteLine(Name);
// Displaying new line character in c#
Name = "One\nTwo\nThree";
Console.WriteLine(Name);
// Displaying new line character in c#
Name = "c:\\Pragim\\DotNet\\Training\\Csharp";
Console.WriteLine(Name);
// C# verbatim literal
Name = @"c:\Pragim\DotNet\Training\Csharp";
Console.WriteLine(Name);
}
}
}
0 comments:
Post a Comment
Note: only a member of this blog may post a comment.