1
Answer

c# compile errors

martycom

martycom

19y
2k
1
serialize3.cs(28,16): error CS1501: No overload for method 'File' takes '1' arguments serialize3.cs(29,18): error CS1501: No overload for method 'Open' takes '1' arguments I copied code from the article "Serializing objects in c# by Bepin Joshi", ran a compile and got the error messages above. I don't have enough knowledge to correct them. I think it has something to do with the code being older (1991).I have copied the code below. Any suggestions would be appreciated. using System; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; public class SerialTest { public void SerializeNow() { ClassToSerialize c=new ClassToSerialize(); File f=new File("temp.dat"); Stream s=f.Open(FileMode.Create); BinaryFormatter b=new BinaryFormatter(); b.Serialize(s,c); s.Close(); } public void DeSerializeNow() { ClassToSerialize c=new ClassToSerialize(); File f=new File("temp.dat"); Stream s=f.Open(FileMode.Open); BinaryFormatter b=new BinaryFormatter(); c=(ClassToSerialize)b.Deserialize(s); Console.WriteLine(c.name); s.Close(); } public static void Main(string[] s) { SerialTest st=new SerialTest(); st.SerializeNow(); st.DeSerializeNow(); } } public class ClassToSerialize { public int age=100; public string name="bipin"; }
Answers (1)