Word function in C#

  • Thread starter Thread starter Fred
  • Start date Start date
F

Fred

Is there a function already in existance that will do something like this:

word(string,char,int)

word("This is my life."," ",3)
would return "my"

My real reason for asking, is I am going to have something like this:
acdefg~hijklmnop~qrstuvwxyz

and I need to return
hijklmnop

Thanks
 
Take a look at instance Split(params char[]) or static Regex.Split(string,
string);
these return string[], so taking the index you want is simple.
 
...
Is there a function already in existance that will do something like this:

word(string,char,int)

word("This is my life."," ",3)
would return "my"

My real reason for asking, is I am going to have something like this:
acdefg~hijklmnop~qrstuvwxyz

and I need to return
hijklmnop

string s = "acdefg~hijklmnop~qrstuvwxyz";

string[] sa = s.Split('~');

string r = sa[1]; // "hijklmnop"

// Bjorn A
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top