guy*_*uyl 2 c# design-patterns rule
我很久以前就读过一条关于使用一个对象的规则,由于null可能性,我们不应该从一个类指向另一个类.
class Foo
{
public Bar Bar1 {get; set;}
public Foo()
{
}
}
class Bar
{
public string Name{ get; set;}
}
Foo foo = new Foo();
foo.Bar1.Name;
Run Code Online (Sandbox Code Playgroud)
在这种模式之后召集的法律或规则是什么?