Warning: count(): Parameter must be an array or an object that implements Countable in /home/devartplus/devartplus.com/wp-content/plugins/maxblogpress-ping-optimizer/maxblogpress-ping-optimizer.php on line 455

Warning: Use of undefined constant user_level - assumed 'user_level' (this will throw an Error in a future version of PHP) in /home/devartplus/devartplus.com/wp-content/plugins/ultimate-google-analytics/ultimate_ga.php on line 524

Archive

Posts Tagged ‘Struct’

Deep copy against shallow copy in .Net C# dealing with mutable Structs

May 13th, 2011 No comments

Warning: Use of undefined constant user_level - assumed 'user_level' (this will throw an Error in a future version of PHP) in /home/devartplus/devartplus.com/wp-content/plugins/ultimate-google-analytics/ultimate_ga.php on line 524

In this post I won’t explain the difference between deep copy and shallow copy, what is reference type and Value type – there are plenty stuff about this in the web. I want to share with you some problematic behavior/bug that we found out in application as a result of luck of understanding in current materials.
This issue can be very tricky and hard to debug in runtime, so we need to be wide-awake.

For example you have very simple struct like follows (holds array of points which describes polygon):

public struct MyPolygon
{
	Point[] points;
}

Read more…

Categories: .Net, C# Tags: ,