c# - Copy a class to another? -


i have

class {     public int a;     public string b; } 

how can copy a? in c++ know *a1 = *a2;. there similar in c#? know write generic solution using reflection hope exist already.

i'm considering changing a nullable struct.

step 2 i'll need do

class b : {} class c : {} 

and copy base data b c.

i have used binary serialization. basically, serialize instance memory stream. then, deserialize out of memory stream. have exact binary copy. deep copy, rather shallow copy.

class = new classa();  class b = myserializationmethod(a); 

for shallow copy can use object.memberwiseclone


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -