2

This is code of the Object:

[Serializable]
public class AppConfig
{
    public static string host {
        get{ return "192.168.1.133";}
    }

    public static int port {
        get{ return 2456;}
    }

    public bool autoLogin;
    public static StartupData startupData;
    public StartupData savedStartupData;

    public void SaveStartupData (StartupData sd)
    {
        this.savedStartupData = sd;
        AppConfig.startupData = sd;
    }
}

If I initialize the Object inside the Catch Exception block:

try {

} catch (Java.IO.FileNotFoundException ex) {
    //Do something here
    AppConfig appConfig = new AppConfig ();
    appConfig.SaveStartupData (startupData);
}

then the appConfig variable is null. But on the contrary If I initialize it outside the Catch Exception then appConfig is not null. I don't know why, It is so absurd. Everybody please explain to me.

4

0 回答 0