none
Deleted RRS feed

Answers

All replies

  • So here is an some input(value of somestring): 

    "something":"null",
    "something2":"blabla"

    string something = null;
    
    if(somestring.Contains(something)){
    something = Regex.Match(somestring, "\"something\":\"(.+?)\"").Groups[1].ToString();
    }
    else{
    goto End;
    }
    
    //Something is being done here with string something
    
    End:;

    And in this case when I try to reference string something I get a NullReferenceException


    "null" is a string literal which contains four characters.

    C# Constants and Literals
    https://www.c-sharpcorner.com/UploadFile/f0b2ed/C-Sharp-constants-and-literals/

    null is a keyword that represents a null reference.

    null (C# Reference)
    https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null

    - Wayne

    Saturday, April 20, 2019 7:37 AM
  • if(someething != null) { if(somestring.Contains(something)){ something = Regex.Match(somestring,

    " "\"something\":\"(.+?)\"").Groups[1].ToString();} else{ goto End; } }



    What does End do, becuase you could just use "return" I believe to leave the method at that point if End is just an exit of the method that's doing nothing?
    Saturday, April 20, 2019 7:37 AM
  • Hi

    Is your problem solved? If so, please post "Mark as answer" to the appropriate answer, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 22, 2019 1:37 AM
    Moderator