【转载】#273 - Parameter Modifier Summary
Here's a summary of the different parameter modifiers and how the behavior changes for each, when using them with value-typed and reference-typed variables.
- No modifier - value types
- Copy of value passed to method
- Method can read value
- No modifier - reference types
- Reference to object passed to method
- Method can read/write object contents
- ref modifier - value types
- Reference to variable passed to method
- Method can read/write variable
- ref modifier - reference types
- Reference to object reference passed to method
- Method can read/write object contents
- Method can change reference to point to new object
- out modifier - value types
- Reference to variable passed to method
- Method must write new value to variable
- out modifier - reference types
- Reference to object reference passed to method
- Method must change reference to point to new object
posted on 2014-03-10 15:52 yuthreestone 阅读(191) 评论(0) 编辑 收藏 举报