C++代码
float* prob ;
gmax = 255;
while (prob[gmax] == 0 && gmax > 0)
gmax--;粘在C#中
第三行
产生错误:使用了未赋值的局部变量"prob".如何解决?
本人菜鸟,望高人指点,小女子在此谢过。
float* prob ;
gmax = 255;
while (prob[gmax] == 0 && gmax > 0)
gmax--;粘在C#中
第三行
产生错误:使用了未赋值的局部变量"prob".如何解决?
本人菜鸟,望高人指点,小女子在此谢过。
解决方案 »
- vs2005下的C#winform程序,问题是怎样让配置文件里连接access数据库的路径是可执行程序所在的目录?
- 关于线程异步的问题,求解
- 菜鸟请教关于多线程复制文件的问题?
- c#.net中怎样用DataGrid控件显示Sql Server数据库中的内容呢
- 请问怎么把这个代码做成一个方法?
- 事件是否一定要方法引发?
- 给定一个中文字符,在C#中如何判断该字符为中文字符?
- 利用web端口发短信问题,关于中文字符串乱码~!!!!!!!!
- 关于委托与事件
- 请问,如何得到ArrayList中的某一个元素的值?
- 向大牛请教方案实现路线,请高手指点,非常感谢!
- 【求助】采用数据绑定的RadioButtonList,如何得到item.count
float* prob = new float[255] ;
unsafe static void Main(string[] args)
{
//写法一,分配在堆上
int gmax = 255;
fixed (float* prob = new float[gmax])
while (prob[gmax] == 0 && gmax > 0)
gmax--; //写法二,分配在堆栈
int gmax = 255;
float* prob = stackalloc float[gmax];
while (prob[gmax] == 0 && gmax > 0)
gmax--;
}
直接
float[] prob=new float[55];
就可以的
C#的话float[] prob = new float[255]{1.2,1.3,...............................};
gmax = 255;
while (prob[gmax] == 0 && gmax > 0)
gmax--;
别忘了DELETE。UNSAFE里边的东西GC不管擦屁股的。