Hi i am having difficulty passing the contence of a struct to a class. I have constructed the class without any errors. However when i try to pass the struct with just its name i get a not declaired compiling error. I have no idea how i can do this can someone please help?

//struct class
/// <summary>
	/// Summary description for Class employeeStructur.
	/// This class holds the data structur for the records held within
	/// the employee file, the backup of this file and the archive of this file.
	/// </summary>
	//[StructLayout(LayoutKind.Sequential)]
	public struct employeeRecord
	{
		public char status;
		public int employeeNo;
		public string lastName;
		public string firstName;
		public DateTime dateBirth;
		public string homePoneNo;
		public string mobPhoneNumber;
		public string houseNo;
		public string addressRoad;
		public string addressTown;
		public string addressCounty;
		public string addressPostCode;
		public DateTime startDate;
		public DateTime endDate;
		public string userName;
		public string password;
		public int accessLevel;
		public string department;
		public decimal salary;
		public DateTime lastUpdate;
		public int updatedBy;
	}
//Main class	
employeeRecord newRecord;
//Large amount of code to accept input and validate
//for each struct component
//subroutine call passing the file stream, binnary writer and structure
changeFile.recordWriter(empFileStream,empFileWriter,newRecord);
//the class being called is layed out as
	public employeeRecord returnRecord(FileStream theFile, BinaryReader theReader,employeeRecord theRecord)
{
//method to read one entire record
employeeRecord returnRecord = theRecord;
returnRecord.status=theReader.ReadChar();
returnRecord.employeeNo=theReader.ReadInt32();
returnRecord.userName=theReader.ReadString();
returnRecord.password=theReader.ReadString();
returnRecord.accessLevel=theReader.ReadInt32();
returnRecord.lastName=theReader.ReadString();
returnRecord.firstName=theReader.ReadString();
returnRecord.dateBirth= DateTime.Parse(theReader.ReadString());
returnRecord.houseNo=theReader.ReadString();
returnRecord.addressRoad=theReader.ReadString();
returnRecord.addressTown=theReader.ReadString();
returnRecord.addressCounty=theReader.ReadString();
returnRecord.addressPostCode=theReader.ReadString();
returnRecord.homePoneNo=theReader.ReadString();
returnRecord.mobPhoneNumber=theReader.ReadString();
returnRecord.startDate=DateTime.Parse(theReader.ReadString());
returnRecord.endDate=DateTime.Parse(theReader.ReadString());
returnRecord.department=theReader.ReadString();
returnRecord.salary=theReader.ReadDecimal();
returnRecord.lastUpdate=DateTime.Parse(theReader.ReadString());
returnRecord.updatedBy=theReader.ReadInt32();
return returnRecord;

}
public void recordWriter( FileStream theFile, BinaryWriter theWriter,employeeRecord theRecord)
{
//method to write one entire record
theWriter.Write(theRecord.status);
theWriter.Write(theRecord.employeeNo);
theWriter.Write(theRecord.userName);
theWriter.Write(theRecord.password);
theWriter.Write(theRecord.accessLevel);
theWriter.Write(theRecord.lastName);
theWriter.Write(theRecord.firstName);
theWriter.Write((theRecord.dateBirth).ToShortDateString());
theWriter.Write(theRecord.houseNo);
theWriter.Write(theRecord.addressRoad);
theWriter.Write(theRecord.addressTown);
theWriter.Write(theRecord.addressCounty);
theWriter.Write(theRecord.addressPostCode);
theWriter.Write(theRecord.homePoneNo);
theWriter.Write(theRecord.mobPhoneNumber);
theWriter.Write((theRecord.startDate).ToShortDateString());
theWriter.Write((theRecord.endDate).ToShortDateString());
theWriter.Write(theRecord.department);
theWriter.Write(theRecord.salary);
theWriter.Write((theRecord.lastUpdate).ToShortDateString());
theWriter.Write(theRecord.updatedBy);
}
	}

unfortunatly without giving all the code it is still a bit difficult to see what is happening.

any help you could give would be great
thanks

I get a build. I had to change this to

employeeRecord newRecord = new employeeRecord();

though.

Thank you. I have been trying to work it out and had stumbled accros it by accident, but thanks for taking the time to look.

This article has been dead for over six months. Start a new discussion instead.