我做了一個條件,如果變量爲null。但是這個代碼仍然因爲null變量而破壞了應用程序。如果條件錯誤?
CODE:
var page = IsolatedStorageSettings.ApplicationSettings["qsPage"];
var hash = IsolatedStorageSettings.ApplicationSettings["Ayath"];
if (page == null && hash == null)
// or if i use if (page == null || hash == null)
{
MessageBox.Show("No Bookmark has been saved !");
}
else
{
NavigationService.Navigate(new Uri("/myWeb.xaml?Page=" + page + "&id=" + hash, UriKind.Relative));
}
您應該放置一個斷點,在調試中啓動您的應用程序並查看哪個變量爲空。 –
兩者都爲空... –
它是否在var頁面中斷? –