且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

这是真的,使用和QUOT;这"之前在C#中使用更多的内存参数?

更新时间:2022-05-22 08:53:24

如果你的意思是字段,然后没有。编译器注入本(的 ldarg.0 )您是否使用它明确(this.foo)或隐式(富)。

If you mean fields, then no. The compiler injects "this" (ldarg.0) whether you use it explicitly (this.foo) or implicitly (foo).

它,然而,拿5个字符你的源代码等开发硬盘的字节屈指可数。它将使编译IL或运行时恰好零差价

It does, however, take 5 more characters in your source code... so a handful of bytes on your development hard disk. It will make exactly zero difference in the compiled IL or at runtime.

有两种情况,其中使用这个变化的东西:

There are two scenarios where use of "this" changes things:


  • 当有同名的( this.foo = foo的; )的变量/参数

  • 解决扩展方法( this.SomeMethod();)当

  • when there is a variable/parameter with the same name (this.foo = foo;)
  • when resolving extension methods (this.SomeMethod();)