dotnet-practitioner
dotnet-practitioner

Reputation: 14148

parsing string for value having newline character

In C#, what is the best way to parse the following string to capture the actual value "Yes" ?

InnerText = "\nPer Diem Allowed\n Per Diem Allowed\n Yes\n

In other words, I want to detect the very last \n and capture the word what is before that.

Upvotes: 0

Views: 145

Answers (1)

dbugger
dbugger

Reputation: 16399

string[] parts = InnerText.Split("\n".ToCharArray());
string partIWant = parts[parts.Length - 2];

Upvotes: 3

Related Questions