Avoiding Language Keyword Conflicts-C#

If you really want to use an identifier that clashes with a keyword, you can qualify it with the @ prefix. For instance:

 class class  {...}    // illegal
 class @class {...}    // legal

The @ the symbol doesn’t form part of the identifier itself, so @myVariable is the same as myVariable. check out this example

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication7
{
   class Program
   {
       static void Main(string[] args)
       {
           int @int = 10;
           double @double = 10.121;
           float @float = (float)(@int + @double);
           Console.WriteLine(@float.ToString());
           Console.Read();

       }
   }
}

إرسال تعليق

Please do not post any spam link in the comment box😊

أحدث أقدم

Blog ads

CodeGuru