Search code examples
c#stringreader

C# Reading particular values in a string


I have the following line from a string:

colors numResults="100" totalResults="6806926"

I want to extract the value 6806926 from the above string How is it possible?

So far, I have used StringReader to read the entire string line by line. Then what should I do?


Solution

  • Consider the this is in Mytext of string type variable

    now

    Mytext.Substring(Mytext.indexof("totalResults="),7); 
    

    //the function indexof will return the point wheres the value start, //and 7 is a length of charactors that you want to extract

    I am using similar of this ........