Support us .Net Basics C# SQL ASP.NET Aarvi MVC Slides C# Programs Subscribe Download

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

It would be great if you can help share these free resources