Last active
August 29, 2015 14:19
-
-
Save step5748/c7972183b34632c1db91 to your computer and use it in GitHub Desktop.
DeepCopy.csの使い方
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// コピーしたいテストクラス | |
[System.Serializable] | |
public class item | |
{ | |
public int id; | |
public string name; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// コピー処理サンプル | |
void Test() | |
{ | |
item a = new item(); | |
a.id = 12345; | |
a.name = "hello"; | |
item b; | |
// 拡張メソッド | |
b = ( item )a.DeepCopy(); | |
// ジェネリックメソッド | |
b = DeepCopyHelper.DeepCopy< item >( a ); | |
b.id = 54635; | |
b.name = "Fine!"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment