Hi Friends,
I am getting the following error with my code
"Object reference not set to instance of the object" .
My code goes as follows:

...
...
string[] isem= new string[125];
decimal[] perc = new decimal[125];
student s1=new student();
...
...
public void func()
{

isem = new string[125];
perc = new decimal[125];
string[] temproll=new string[125];
int j=0;
sem = s1.calcallperc1(..., ..., ....);//calcperc1 returns an array
j=-1;
foreach (string s in isem)
                    {
                                             
                        temproll[++j] = s.Split(' ')[0];
                        perc[j] = Convert.ToDecimal(s.Split(' ')[1]);

                    }


}
...

Please help!!

Hi Friends,
I am getting the following error with my code
"Object reference not set to instance of the object" .
My code goes as follows:

...
...
string[] isem= new string[125];
decimal[] perc = new decimal[125];
student s1=new student();
...
...
public void func()
{

isem = new string[125];
perc = new decimal[125];
string[] temproll=new string[125];
int j=0;
sem = s1.calcallperc1(..., ..., ....);//calcperc1 returns an array
j=-1;
foreach (string s in isem)
                    {
                                             
                        temproll[++j] = s.Split(' ')[0];
                        perc[j] = Convert.ToDecimal(s.Split(' ')[1]);

                    }


}
...

Please help!!

I think there is mistake in this statement

sem = s1.calcallperc1(..., ..., ....);//calcperc1 returns an array

Either it should be isem or the sem should be declared as an array variable since the function returns the an array.

Hope this would be help you!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.