Fra Java til C#
Kan dette nemt oversættes fra java til C#?public static void gem(String s, Object o)
{
File f = new File(s);
try {
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(f));
oos.writeObject(o);
oos.close();
}
catch (IOException e) {
JOptionPane.showMessageDialog(null,"Fejl ved skrivning på filen " + s + ". Systemfejl: "+ e.getMessage());
}
}
public static Object læs(String s)
{
File f = new File(s);
try {
ObjectInputStream oos = new ObjectInputStream(new FileInputStream(f));
Object o = oos.readObject();
oos.close();
return o;
}
catch (IOException e) {
return null;
}
catch (ClassNotFoundException e) {
JOptionPane.showMessageDialog(null,"Klasse ukendt for objektet i filen " + s + ".");
return null;
}
}
