为什么即使一切都是空的,这个程序仍然输出“not null”?!我必须改变什么才能最终使它为空?
“您的帖子没有太多解释代码部分的上下文;请更清楚地解释您的场景。” 对不起……
public interface IDrawable
{
void Draw();
}
public interface IAdvancedDraw : IDrawable
{
void DrawInBoundingBox();
void DrawUpsideDown();
}
public class BitmapImage : IAdvancedDraw
{
public void Draw() { }
public void DrawInBoundingBox() { }
public void DrawUpsideDown() { }
}
class Program
{
static void Main( string[] args )
{
BitmapImage myBitmap = new BitmapImage();
if ((IAdvancedDraw)myBitmap != null){
Console.WriteLine("not null");
}
Console.ReadLine();
}
}