zoukankan      html  css  js  c++  java
  • .net 实例化对象

    定义TestClass,在调用的地方

    TestClass a;

    如果下面有引用

    a.Property,VS会报错,而如果

    TestClass a = null;

    再次调用的话则不会报错。

    TestClass a; DebugIL代码:

    .method private hidebysig static void  Main(string[] args) cil managed
    {
      .entrypoint
      // Code size       2 (0x2)
      .maxstack  0
      .locals init ([0] class ConsoleApplication1.TestClass a)
      IL_0000:  nop
      IL_0001:  ret
    } // end of method Program::Main
    

    TestClass a = null; DebugIL代码:

    .method private hidebysig static void  Main(string[] args) cil managed
    {
      .entrypoint
      // Code size       4 (0x4)
      .maxstack  1
      .locals init ([0] class ConsoleApplication1.TestClass a)
      IL_0000:  nop
      IL_0001:  ldnull
      IL_0002:  stloc.0
      IL_0003:  ret
    } // end of method Program::Main
    

    TestClass a; Release IL代码,VS会优化掉该语句

    .method private hidebysig static void  Main(string[] args) cil managed
    {
      .entrypoint
      // Code size       1 (0x1)
      .maxstack  8
      IL_0000:  ret
    } // end of method Program::Main
    

    TestClass a = null; Release IL代码,VS同样会优化掉该句

    .method private hidebysig static void  Main(string[] args) cil managed
    {
      .entrypoint
      // Code size       1 (0x1)
      .maxstack  8
      IL_0000:  ret
    } // end of method Program::Main
    

    先Mark,以后在具体研究区别

  • 相关阅读:
    SRS之SrsRtmpConn::service_cycle详解
    SRS之SrsRtmpServer::connect_app详解
    SRS之RTMP连接处理线程conn:接收客户端推流
    SRS之RTMP handshake
    SRS之RTMP的TCP线程(即监听线程)
    CSPS模拟 77
    CSPS模拟 76
    CSPS模拟 75
    CSPS模拟 74
    CSPS模拟 73
  • 原文地址:https://www.cnblogs.com/NailClipper/p/4643064.html
Copyright © 2011-2022 走看看