【发布时间】:2016-01-27 07:21:38
【问题描述】:
我正在尝试使用 c# 接口概念为圆形和正方形区域编写小程序。在给出特定条件if (args[0] == "S") 时出现错误IndexOutOfRangeException:
if (args[0]=="S")
fig = new Square();
if (args[0]=="C")
fig = new Circle();
【问题讨论】:
-
您没有检查 args 数组是否具有非零长度。最好将代码作为文本包含在此处而不是链接到图像。