public class B1
{
public static void MyFunc(){ ; }
}
public class B2
{
private B1 b1;
public B1 B1
{
get { return b1; }
set { b1 = value; }
}
public void Foo(){
B1.MyFunc();
}
}
除了 case 之外,我给事物命名为与它们的类型相同的名称: 我的方法和属性是“ lowerCase”; 因此我不会遇到 MiffTheFox 所遇到的问题。
public class B1
{
public static void myFunc(){ ; }
}
public class B2
{
private B1 m_b1;
public B1 b1
{
get { return m_b1; }
set { m_b1 = value; }
}
public void Foo()
{
B1.myFunc(); //this is Ok, no need to use namespace
}
}
public class Car {
public enum Make {
Chevy,
Ford
};
// No good, need to pull Make out of the class or create
// a name that isn't exactly what you want
public Make Make {
get; set;
}
}