未将对象引用设置到对象的实例 2011-10-12 21:28 提问者:Lee2011_6_7 | 悬赏分:5 | 浏览次数:2061 次 using System; using System
Collections
Generic; using System
ComponentModel; using System
Data; using System
Drawing; using System
Linq; using System
Text; using System
Windows
Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public class oper { public int i; public double j; public char k; } private void button1_Click(object sender, EventArgs e) { oper[] myOper = new oper[10]; myOper[0]
i = 1; //这一行报错,未将对象引用设置到对象的实例 } } } 问题补充: 就是问一下这个问题” 未将对象引用设置到对象的实例“ 是什么意思,该怎么解决~ 2011-10-12 22:23 最 佳答案 首先这里报这个错是因为 myOper[0]为空,取不到它的属性i,所以会报错
其次这里的oper[] myOper = new oper[10]仅仅是实例化了一个数组,但是数组里面的对象是没有实例化的,仅仅是声明了一串 oper 对象而已
再次为什么这里如果是int[] abc=new int[10]或者 char[