locked
String Contain Failing Condition RRS feed

  • Question

  • User194385433 posted

    Hi,

    Why Condition is failing here.It has to print "yes".

       string list = "SUMMARY,Professional Summary";
       string singlePara = "SUMMARY  Software Engineer working as a Specialist Web Developer in .NET Technologies".ToLower();
                
    if (list.ToLower().Split(',').Contains(singlePara)) { Console.WriteLine("yes"); }

    Wednesday, June 14, 2017 4:53 PM

Answers

  • User753101303 posted

    Hi,

    My understanding is that you want (another option would be to use Linq) :

                string[] list = { "SUMMARY", "Professional Summary" };
                string singlePara = "SUMMARY  Software Engineer working as a Specialist Web Developer in .NET Technologies".ToLower();
                Console.WriteLine(Array.Exists(list,value=>singlePara.Contains(value.ToLower())));
    

    ie for each string from your array you want to see if at least one value is found in the singlePara string ?

    For now you are using Array.Contains ie you are looking if the singlePara string is found in your array.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 14, 2017 5:16 PM