string partial_information = "";
dynamic obj;
while (...)
{
... (out information);
if (partial_information == "")
{
try
{
obj = JsonConvert.DeserializeObject(information);
}
catch (Newtonsoft.Json.JsonReaderException ex)
// 'information' only contains the first part of the actual information
{
partial_information = information;
}
}
else
{
obj = JsonConvert.DeserializeObject(partial_information + information);
// in the previous loop, some 'information' was written to 'partial_information'.
// Now the concatenation of both is used for deserialising the info.
partial_information = ""; // don't forget to re-initialise afterwards
}
if (obj.Some_Property != null) // <-- Compiler error (!!!)
{
با این حال، این کامپایل نمیشود: خط خطای کامپایلر if (obj.Some_Property != null)
ایجاد میکند CS1065
:Use of unassigned local variable 'obj'
: .
به نظر من، این بیمعنی است، همانطور که obj
حتی خارج از کل [موضوع] اعلام شده است.while
-loop نیز اعلام شده است.
چطور میتوانم این را مدیریت کنم؟