Original Post
How do i port this part of code to C#: Full semi-Source here: Originaly started Here
static {
logSystem = new MyLogSystem();
}
public final class MyLogSystem {
private static MyLogSystem logSystem;
private static File logFile;
static {
logSystem = new MyLogSystem();
}
// Private constructor
private MyLogSystem() {
try {
logFile = new File("logs.txt");
if (!logFile.exists())
logFile.createNewFile();
} catch (IOException ioex) {
ioex.printStackTrace();
}
}
public static MyLogSystem getInstance() {
return logSystem;
}
public void writeOnLog(Exception e) {
// write on the log
}
}
// Then, you use it like this:
Exception e;
MyLogSystem.getInstance().writeOnLog(e);