Hi
I converted vb6 code into C# but facing an error.
Suppose we have Person
--------------------------------------------
C#
public class Person
{
private int intID;
private string strName;
private string strSurname;
public Person()
{
intID = -1;
strName = "";
strSurname = "";
}
public int ID
{
get
{
return intID;
}
set
{
intID = value;
}
}
public string Name
{ get
C#
{
return strName;
}
set
{
strName = value;
}
}
public string Surname
{
get
{
return strSurname;
}
set
{
strSurname = value;
}
}
} --------------------------------------------------------------------
I want to write this class into file. I was using
Code
Person entP = new Person();
entP.ID = 1;
entP.Name= "john";
entP.Surname ="doe";Code
FileSystem.FileOpen(1, "test_file", OpenMode.Binary);
FileSystem.FilePutObject(1, entP,-1);
FileSystem.FileClose(1);But it throws an error
Unhandled Exception: System.ArgumentException: File I/O with type 'Person' is not valid.
It seems FilePutObject does not support classes. Is there alternative way to do same task?
Please guide
thanks
Answers
Know the answer? Post it. Somebody with the same question will find it here.