-1

Possible Duplicate:
Actual Performance of Fields vs. Properties

Is there a known performance difference between setting a field by method AND setting it via property?

(I just wonder if implementing a property emits some extra stuff to IL which makes the PROPERTY work slower than directly callind a method that sets the value)

Community
  • 1
  • 1
pencilCake
  • 51,323
  • 85
  • 226
  • 363

1 Answers1

2

Properties are methods. If you declare a property named MyProperty with both get/set then the compiler will emit two methods: get_MyProperty and set_MyProperty, decorating them to make understandable to others (who will use the property) that that methods are getter/setter of a property. For example the first version of managed C++ didn't hide this trick. Take a look to decompiled version of a method and a property setter (for example) and you'll see they aren't different, what you see in your code is sugar to make them "nice".

Adriano Repetti
  • 65,416
  • 20
  • 137
  • 208