79728710

Date: 2025-08-07 14:16:53
Score: 2
Natty:
Report link
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‎ نیز اعلام شده است.

چطور می‌توانم این را مدیریت کنم؟

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • No latin characters (2.5):
  • Low reputation (1):
Posted by: مجتبی. جوهری.