0

I am getting a return string from web service that I am calling. Now I want to look for specific value which should be present in that return string. Return string is something like this:

pg_response_type=A
pg_response_code=A01
pg_response_description=APPROVED
endofdata

Now I want to check in this string that if pg_response_code=A01 is present or not. I know I have to for loop in the string. What should be the code...? Suppose I am storing this string in string Response;

1
  • 4
    Whats wrong with the Contains method? e.g if (response.Contains("pg_response_code=A01")... Commented May 31, 2011 at 16:01

2 Answers 2

6

Simply use String.Contains:

bool contains = response.Contains("pg_response_code=A01")
Sign up to request clarification or add additional context in comments.

Comments

1

Without writing a parser or looping you can still check for specific values like this:

string response; //response in here.

if(response.contains("pg_response_code=A01"))
{
 //do something
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.