次のコードがあります。
try
{
var result =
from entry in feed.Descendants(a + "entry")
let content = entry.Element(a + "content")
let properties = content.Element(m + "properties")
let notes = properties.Element(d + "DetailsJSON")
let questionMessage = properties.Element(d + "QuestionText")
let title = properties.Element(d + "Title")
let partitionKey = properties.Element(d + "PartitionKey")
where partitionKey.Value == "0001I" && title != null
select new Question
{
Notes = notes.Value ?? "n/a",
Title = title.Value,
QuestionMessage = questionMessage.Value
};
// xx
IList<Question> resultx = null;
foreach (var question in result)
{
resultx.Add(question);
}
// yy
return result;
}
catch (Exception ex)
{
throw new InvalidOperationException("GetQuestions.Get problem", ex);
};
xx と yy の間のコードの部分をコメントアウトすると、機能します。そうしないと、次のような例外が発生します。
ex {"Object reference not set to an instance of an object."} System.Exception {System.NullReferenceException}
誰かが私が間違っているかもしれないことについていくつかのアイデアを教えてもらえますか?