这是真的,使用和QUOT;这"之前在C#中使用更多的内存参数? [英] Is it true that using "this." before the parameters in c# uses more memory?

查看:139
本文介绍了这是真的,使用和QUOT;这"之前在C#中使用更多的内存参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不仅仅是调用参数,因为它是?

than just to call the parameter as it is?

推荐答案

如果你的意思是字段,然后没有。编译器注入本(的 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();)

这篇关于这是真的,使用和QUOT;这"之前在C#中使用更多的内存参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆