If some one knows any more ways of doing this in .NET and also what is your opinions about that approaches? Which approach you choose and why?
Here is the tests of d
Have you tried overriding the Clone method to copy object instances? This way, you get a new student object like this:
for (int i = 0; i < 1000000; i++)
{
StudentDTO itemT = _student.Clone();
}
I find this approach the easiest way of copying objects into new objects, though I haven't done any speed tests to find out how well it performs against the methods you suggest.
It is also possible to use T4 to generate classes that will generate property copy code.
Good: runs as fast as it is possible Bad: "coding" in T4 Ugly: Making build scripts that allow you to compile it all in one go
the Clone is for copy the same Type not for copying from 2 different objects Type then can't be used for this scope.