locked
Comma separated value find the value in a comma separated string, RRS feed

  • Question

  • User179837873 posted

    I have a string like

     

    human, roti, makan, ghar, house, language, english, india, US, master, teacher, html, code, asp, jsp

     

    i need code for find the input string.

     

    thanks

    Rambhopal

    Monday, July 11, 2011 8:24 AM

Answers

  • User-1516073966 posted

    you split the string with comma(,)

    string str = "human, roti, makan, ghar, house, language, english, india, US, master, teacher, html, code, asp, jsp";
    
    string[] list = str.Split(',');
    
    foreach(string s1 in list)
    {
       if(s1 == "searchstring)
       {
         //Here you find the string which matches.
       }
    }
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 11, 2011 8:27 AM
  • User-366017857 posted
    string Col = "human, roti, makan, ghar, house, language, english, india, US, master, teacher, html, code, asp, jsp";

    string[] collect = Col.Split(',');

    foreach(string item in collect)
    {
    if(string.Equals(item,"YourInputStringHere",StringComparison.OrdinalIgnoreCase))
    {
    //Add your code to excute if string match
    }
    }

    Use equals method and stringcomparison type
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 11, 2011 8:37 AM

All replies

  • User-1516073966 posted

    you split the string with comma(,)

    string str = "human, roti, makan, ghar, house, language, english, india, US, master, teacher, html, code, asp, jsp";
    
    string[] list = str.Split(',');
    
    foreach(string s1 in list)
    {
       if(s1 == "searchstring)
       {
         //Here you find the string which matches.
       }
    }
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 11, 2011 8:27 AM
  • User-366017857 posted
    string Col = "human, roti, makan, ghar, house, language, english, india, US, master, teacher, html, code, asp, jsp";

    string[] collect = Col.Split(',');

    foreach(string item in collect)
    {
    if(string.Equals(item,"YourInputStringHere",StringComparison.OrdinalIgnoreCase))
    {
    //Add your code to excute if string match
    }
    }

    Use equals method and stringcomparison type
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 11, 2011 8:37 AM
  • User-423124851 posted

    Your question is not clear to us. Please explain properly

    Monday, July 11, 2011 8:37 AM