Does Properties increase memory size of Instances?

后端 未结 5 578
天涯浪人
天涯浪人 2021-01-19 10:30

This is probably a stupid question, but does object Properties occupy any memory per instance?

As I\'ve understand it when you instantiate an object each value field

5条回答
  •  悲哀的现实
    2021-01-19 11:19

    If you look at a compiled C# class through for instance reflector you will see that the compiler actually translates the properties into get and set methods, auto properties are translated into get and set methods with a backing field, so the field will take up as much room as a regular field

提交回复
热议问题