Support us .Net Basics C# SQL ASP.NET ADO.NET MVC Slides C# Programs Subscribe Buy DVD

Part 4 - C# Tutorial - String type

Suggested Videos
Part 1 - Introduction to C#
Part 2 - Reading and writing to console
Part 3 - Built-in types

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
With Verbatim Literal : @"C:\Pragim\DotNet\Training\Csharp"; // Better 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);
        }
    }
}

No comments:

Post a Comment

If you like this website, please share with your friends on facebook and Google+ and recommend us on google using the g+1 button on the top right hand corner.