varのnullをチェックしようとしましたが、「オブジェクト参照がオブジェクトのインスタンスに設定されていません」とスローされます。
private void GenerateImage()
{
//Webster.Client.Modules.Metadata.Helper test = new Webster.Client.Modules.Metadata.Helper();
var selectedstory = Webster.Client.Modules.Metadata.Helper.SelectedStoryItem;
if((selectedstory.Slug).Trim()!=null)
{
//if (!string.IsNullOrEmpty(selectedstory.Slug))
//{
if (File.Exists(pathToImage))
{
}
else
{
this.dialog.ShowError("Image file does not exist at the specified location", null);
}
}
else
{
this.dialog.ShowError("Slug is Empty,please enter the Slug name", null);
}
}
selectedstory.Slugの値がnullであることがわかっているため、if条件を使用してチェックしましたが、if条件ですぐにスローされます。
誰かがチェックする正しい方法を教えてもらえますか?