Variable names with the same name as the @ definition and the default identifier in C #

Source: Internet
Author: User

We can use @ to go up a notation with the same name as the C # built-in marker.

Like what

string " string " ; Console.WriteLine (@string); string " Test " ; Console.WriteLine (test); string " test1 " ; Console.WriteLine (_test1);

Here is the IL code to see the difference

. Method Private HidebysigStaticvoidMain (string[] args)CIL managed{  . EntryPoint  //Code Size (0x5b)  . Maxstack  2  . Locals Init([0]strings, [1] string 'string' ,           [2]string test, [3]string _test1, [4]string[] cs$6$0000,           [5]Int32cs$7$0001,           [6]BOOLcs$4$0002)  il_0000:  NOP  il_0001:  NOP  il_0002:  ldarg.0  il_0003:  Stloc.scs$6$0000  il_0005:  ldc.i4.0  il_0006:  Stloc.scs$7$0001  il_0008:  BR.Sil_001fil_000a:  Ldloc.scs$6$0000  il_000c:  Ldloc.scs$7$0001  il_000e:  Ldelem.ref  il_000f:  stloc.0  il_0010:  NOP  il_0011:  ldloc.0  il_0012:  Pager       void[mscorlib] System.console::writeline (string)  il_0017:  NOP  il_0018:  NOP  il_0019:  Ldloc.scs$7$0001  il_001b:  ldc.i4.1  il_001c:  Add  il_001d:  Stloc.scs$7$0001  il_001f:  Ldloc.scs$7$0001  il_0021:  Ldloc.scs$6$0000  il_0023:  Ldlen  il_0024:  Conv.i4  il_0025:  CLT  il_0027:  Stloc.scs$4$0002  il_0029:  Ldloc.scs$4$0002  il_002b:  BRTRUE.Sil_000ail_002d:  ldstr      "string"  il_0032:  stloc.1  il_0033:  Ldloc.1  il_0034:  Pager       void[mscorlib] System.console::writeline (string)  il_0039:  NOP  il_003a:  ldstr      "Test"  il_003f:  Stloc.2  il_0040:  Ldloc.2  il_0041:  Pager       void[mscorlib] System.console::writeline (string)  il_0046:  NOP  il_0047:  ldstr      "test1"  il_004c:  stloc.3  il_004d:  Ldloc.3  il_004e:  Pager       void[mscorlib] System.console::writeline (string)  il_0053:  NOP  il_0054:  Pagervaluetype [Mscorlib]system.consolekeyinfo [Mscorlib]system.console::readkey ()il_0059:  Pop  il_005a:  ret} //end of Method Program::main

You can see that in fact, this is only useful for built-in identifiers.

Variable names with the same name as the @ definition and the default identifier in C #

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.