Archive

Posts Tagged ‘Struct’

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

May 13th, 2011 No comments

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: ,