一个关于深层拷贝的问题(迷惑在私有构造函数)
一个关于深层拷贝的问题(迷惑在私有构造函数)
地址:
http://topic.csdn.net/u/20080903/16/0f89b388-0c33-4c0f-931c-0520c907fdad.html
一个关于深层拷贝的问题(迷惑在私有构造函数)
地址:
http://topic.csdn.net/u/20080903/16/0f89b388-0c33-4c0f-931c-0520c907fdad.html
用new修饰的方法,在编译期按变量类型调用
所以:
Number number = new IntNumber();
number.ShowInfo();
会显示”base class—“
1 | class Number |
C# Code:
1 | public static void Main3_3_3() |
对应MSIL及其注释:
1 | .method public hidebysig static void Main3_3_3() cil managed |

1 | using System; |

1 | using System; |
粘贴回来格式一片混乱,百度似乎还有图床保护?干脆留个地址在这里
1 | using System; |


1 | using System; |
设计模式—命令模式

1 | using System; |
2008年08月17日 星期日 下午 04:28

1 | using System; |
2008年08月15日 星期五 下午 05:23
松耦合

1 | using System; |
设计模式—单例模式(singleton)

1 | using System; |
设计模式—迭代器模式(昨天停电了……)

设计模式—备忘录模式(CSDN没有恢复迹象……)

using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class 人物状态
{
private int _血;
private int _气;
public 人物状态()
{
_气 = 100;
_血 = 100;
}
public int 血
{
get { return _血; }
set { _血 = value; }
}
public int 气
{
get { return _气; }
set { _气 = value; }
}
public 存档 存档()
{
return new 存档(_血, _气);
}
public void 读档(存档 c)
{
this.气 = c.气;
this.血 = c.血;
}
public void 战斗()
{
System.Random r = new System.Random();
this._血 = r.Next(100);
this._气 = r.Next(100);
}
public void ShowState()
{
Console.WriteLine(this.气 + " " + this.血);
}
}
class 存档
{
private int _气;
private int _血;
public 存档(int x, int q)
{
this._气 = q;
this._血 = x;
}
public int 气
{
get { return _气; }
}
public int 血
{
get { return _血; }
}
}
class 管理器
{
private 存档 savedfile;
public 存档 SavedFile
{
get { return savedfile; }
set { savedfile = value; }
}
}
class 调用者
{
public static void Main()
{
人物状态 r = new 人物状态();
r.ShowState();
管理器 g = new 管理器();
g.SavedFile = r.存档();
r.战斗();
r.ShowState();
r.读档(g.SavedFile);
r.ShowState();
Console.Read();
}
}
}
``
设计模式—组合模式(CSDN依然没有恢复迹象……)

1 | using System; |

1 | using System; |
设计模式—状态模式(今天CSDN竟然上不去,暂时发在这里)

1 | using System; |
1 | using System; |


1 | using System; |
1 | using System; |

1 | using System; |


1 | using System; |