Your expectation of what a deep copy vs a shallow copy does is not correct. A shallow copy copies all value types, and just the references of reference types. A deep copy copies all value types and all reference types.
So your struct already performs a shallow copy when doing:
MyStruct struct2 = struct1;
This code example (console application) shows, that changing a value of the object in the second struct changes also the value of the object in the first struct, because the object has just been copied by reference:
class Program
{
static void Main(string[] args)
{
Test t1 = new Test();
t1.i = 1;
t1.o = new Klasse();
t1.o.i = 1;
Test t2 = t1;
t2.i = 2;
t2.o.i = 2;
Console.WriteLine(t1.i.ToString());
Console.WriteLine(t1.o.i.ToString());
Console.WriteLine(t2.i.ToString());
Console.WriteLine(t2.o.i.ToString());
Console.Read();
}
}
struct Test
{
public int i;
public Klasse o;
}
class Klasse
{
public int i = 0;
}