   [.net] Java to C# code port please
  How do i port this part of code to C#:  static {    logSystem = new MyLogSystem();  }Full semi-Source here: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);Originaly started Here
  Does this not do the same thing?Sorry, but I have never seen the static {} construct in Java before.private logSystem = new MyLogSystem();;  No that will not do it. I need to create Global Class. In this example it logging class.IN the 1st run-time i open filename, and from any class i could just pass informaion directly to log class without reinitializing it again.   ;  static LogFile logFile = new LogFile("Path");should do the trick.. not?   ;  A C# static constructor is the equivalent to Java's static initializers.class A{ static A() {   // Perform class intialization. }}However, in this case, I believe davepermen's solution will give you what you want.   