C# substring type method?
Is there an easy way to get a substring of a string? I am calling a method that returns back an array of values that look similar to:
keys[0] = "All|All";
keys[1] = "Admin|Admin";
keys[2] = "Shop Floor|Shop Floor";
keys[3] = "Development|Development";
keys[4] = "Front Desk|Front Desk";
When I receive the results, I want to break out the results so that All|All becomes All and Admin|Admin becomes Admin. Is there an easy way to get rid of everything after the "|"?
Re: C# substring type method?
Code:
key[n].Split('|')[0]
Re: C# substring type method?
Can also do this way... though CPUWizard has more elegant solution :)
Code:
string[] q = Regex.Split("All|All", "[|]");
MessageBox.Show(q[1].ToString().Trim());
Re: C# substring type method?