Create an object in a class

  • Thread starter Thread starter Raymond Gilbers
  • Start date Start date
R

Raymond Gilbers

Guest
Hello all,

I have written some code in Form1.cs where I have a method called GetFileData


private void GetFileData()
{
char[] seperation = { ',', ' ' };
string[] names;
string temp;
string[] temp2;
char[] MyChar = { 'A', 'D', 'a', 'd', 'C', 'F', 'G' };
int len;
int totChannels;

/* Lots of other code
////////
//////
*/

AnalogChannelInfo analogChannelInfo = new AnalogChannelInfo();


for (int i = 1; i <= totChannels; i++)
{
temp2 = clist[2 + i].Split(seperation);
analogChannelInfo.An = Convert.ToInt32(temp2[0]);
analogChannelInfo.ch_id = Convert.ToInt32(temp2[1]);
analogChannelInfo.ph = Convert.ToInt32(temp2[3]);
analogChannelInfo.ccbm = Convert.ToInt32(temp2[4]);
analogChannelInfo.uu = temp2[5];
}
label1.Text = analogChannelInfo.uu[3];

}


In a separate class file called ClassProcessing.cs I have created an object as shown below

public class ClassProcessing
{
public static int CalcSampleSize(int Ak, int DM)
{
//This formula calculates the size of a sample in bytes
return (Ak * 2) + (2 * (DM / 16)) + 8;
}

}

public class AnalogChannelInfo
{
public int[] An;
public int[] ch_id;
public int[] ph;
public int[] ccbm;
public string[] uu;
public double[] chMult;
public double[] chOffset;
public double[] chSkew;
public int[] minRange;
public int[] maxRange;
public int[] primRatio;
public int[] secRatio;
public string[] scaleID;
}


Unfortunately I get a NullReferenceException The object reference is not set to an instance of an object. I guess I have made a mistake in the ClassProcessing.cs file but I don't know what I have done wrong. Could someone help me please?


Thanks in advance


The object reference is not set to an instance of an objec
The object reference is not set to an instance of an objec

Continue reading...
 
Back
Top