数组=== object ref未设置为object的实例 [英] Array ===object ref not set to an instance of object

查看:59
本文介绍了数组=== object ref未设置为object的实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨evryone,

hi evryone,

int[] users_NoVhInfo= new int[dynamically];
//dynamically m getting size of array and assigining only some values other value remains zero
for Loop
{
users_NoVhInfo[i] = Value; // it''s only for example.its wrking 
}
//

function calling(users_NoVhInfo); /// ERROR.ERROR
.
.
..
void calling(int[] users_NoVhInfo)
{
...........................
}



在上面的代码m中,创建了收集一些值的数组对象..
它将通过调用函数...但是在调用时,它会给出错误" 对象引用未设置为对象的实例 ".... .....我如何解决这个问题...其急切的人



in above code m creating array object which is collecting some values..
and it will pass through calling function... but at the tim of calling it is giving ERROR "OBJECT REFERNCE NOT SET TO AN INSTANCE OF AN OBJECT".........how i can solve this problem...its urgent guys

推荐答案

我认为这不是定义数组的正确方法10个整数:
I don''t think this is the right way to define an array of 10 integers:
users_NoVhInfo[i] = {1,2,3,4,.....};



在这里查看数组声明和初始化: http://msdn.microsoft.com /en-us/library/aa288453(VS.71).aspx [ ^ ]

纠正您的代码,然后发布您的经验.



Have a look at array declaration and initialization here:http://msdn.microsoft.com/en-us/library/aa288453(VS.71).aspx[^]

Rectify your code and then post your experience.


假设提供的代码段是一些伪造的伪代码.检查您的for循环实际上是否按照以下方式进行操作:

Assuming the code snippet provided is some mangled psuedo code. Check your for loop is actually doing something along the lines of:

int[] users_NoVhInfo= new int[10];
for(int i=0;i<10;i++)
{
    users_NoVhInfo[i]=i;
}




然后,您将调用传递到数组中的函数,则不应看到该错误(由于数组).我将使用VS调试器非常仔细地跟踪该阵列发生的情况.




And you''re then calling a function passing in the array, then you shouldn''t see that error (due to the array). I would follow what''s happening to that array very carefully using the VS debugger.


这篇关于数组=== object ref未设置为object的实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆