Jump to content

  • Log In with Google      Sign In   
  • Create Account

m_switch

Member Since 06 Nov 2009
Offline Last Active Dec 19 2011 07:17 PM

Posts I've Made

In Topic: Pros/Cons for Accessing class members - C#

16 January 2011 - 05:56 PM


Note that the semantics of properties and public variables that return value types are different. For public variables, you are directly accessing the variable. However, a property that returns a value type makes a copy of the variable.



In both instances with value types the values are placed onto the evaluation stack and popped into the appropriate stack variable.

...


Also the only difference between a automatic property and providing the backing field yourself in terms of MSIL is the fact that the compiler adds an attribute to the field I believe to indicate it's compiler generated.


This is an implementation detail, I was speaking in reference to the semantics. Visual Studio will actually generate an error when you attempt to modify a copy of a property's backing store (directly).


See http://msdn.microsof...v=vs.71%29.aspx

In Topic: Pros/Cons for Accessing class members - C#

16 January 2011 - 01:37 PM


Consider: in C#, the syntax foo.Field will work to access Field whether Field is a public member or a property. So the best course of action is to begin with public fields, and if you need to refactor to add logic later, drop in a property named Field with the associated logic. No calling code needs to be changed, meaning you only have minor code site updates to make, and everything continues to work swimmingly.

The syntax is the same, but the generated MSIL is different. This means that if you change from a public field to property, you can't do a drop in binary replacement. Calling code still needs to be recompiled.


Note that the semantics of properties and public variables that return value types are different. For public variables, you are directly accessing the variable. However, a property that returns a value type makes a copy of the variable.

In Topic: Games with good melee combat

15 September 2010 - 05:40 PM

Seconding Dark Messiah of Might and Magic (PC, the 360 port was not very good). Easily the most immersive melee combat I've ever experienced.

In Topic: virtual machine memory storage type

11 September 2010 - 07:23 PM

Why not have three (or however many) separate vectors/containers instead of trying to jam everything into one?

In Topic: Flash (action script 2.0) loop problem

09 August 2010 - 02:35 AM

Setting the alpha multiple times in the same frame won't have a visual effect. Only the value at the end of the frame will be used to draw the clip. Either keep state between frames to determine the alpha (loop is unnecessary) or use a tween library like Greensock designed to simplify what you're trying to do.

PARTNERS