我读了一些剧本,似乎很难理解.希望有人能解释为什么第一个:
public static bool ContainsDestroyWholeRowColumn(BonusType bt)
{
return (bt & BonusType.DestroyWholeRowColumn)
== BonusType.DestroyWholeRowColumn;
}
Run Code Online (Sandbox Code Playgroud)
为什么不写bt.Equal(BonusType.DestroyWholeRowColumn)或bt == BonusType.DestroyWhoeRowColumn?第二:
public bool IsSameType(Shape otherShape)
{
if (otherShape == null || !(otherShape is Shape))// check otherShape is not null and it is Shape
throw new ArgumentException("otherShape");
return string.Compare(this.Type, (otherShape as Shape).Type) == 0;
}
Run Code Online (Sandbox Code Playgroud)
如果输入法不是正确的类型.我认为它会立即警觉,为什么他们还需要检查对象的类型最后:
//if we are in the middle of the calculations/loops
//and we have less than 3 matches, return a random one
if(row >= Constants.Rows / 2 …Run Code Online (Sandbox Code Playgroud)