int[] aa =null;
int[] aa1 ={1,2}; aa = aa1;这样没问题 int[] aa =null;
aa = {1,2};这样就报错
为什么?
int[] aa1 ={1,2}; aa = aa1;这样没问题 int[] aa =null;
aa = {1,2};这样就报错
为什么?
解决方案 »
- C#2010在窗体上增加串口控件时,为啥控件跑到了窗体下面去了?
- 没加 "\r "就出现乱码 ???
- 在一个FORM里取的值传到另一个FORM里?
- 给一个类动态加载属性
- 紧急关注! 面试遇到的问题,模式问题 我想问问一定要用.net的remoting么?socket套接字通讯可以么?
- 关于tableadapter的问题
- 在Windows Forms下如何重新绑定Datagrid?
- 将listviewItem的backcolor设置KnownColor.activeCaption不成功:(
- 大家来看
- 求助:winform里datagrid实现数据的录入删除和更新的问题(c#)
- c# 中怎样才可以将一个treeview实例真正保存在另一个treeview实例中?一定结贴!
- 诸位兄弟们,数据库连接失败,急等。。。
int[] aa =null; aa = {1,2}; 这样并没有初始化,没有初始化,就直接赋值,那么肯定错误!int []aa;
aa=new int[2];
aa[0]="abc";
aa[1]="dsfds";
或者int []aa=new int[2];
aa[0]="abc";
aa[1]="dsfds";或者 int[]aa=new int[2]{"abc","dfd"};
aa = new int[] { 1, 2 };
aa = new int[]{1,2}; // 赋值
int[] aa1 = {1,2}; // 声明兼初始化
aa = {1,2};
int[] aa1 = {1,2};
也应该写成
int[] aa1 = new int[]{1,2};
我试了一下没报错
那第一种应该是简写模式吧
int[] aa1 = {1,2};
//象这种写法在javascript称直接量
//在C#貌似没听这“直接量”的说法
//不过这两种写法都正确的,而且也没有褒贬之分,编译后应该是一样的