Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Substrings in C#

Status
Not open for further replies.

raghu75

Programmer
Nov 21, 2000
66
IN
Hi
I have to search for newline character in a string and remove that newline character and copy the string which is on the right side of the newline character to another string.Can any one tell me which are correct functions to use.

Raghu
 
Well, in standart ASCII table new line is 10. So just seek for Convert.ToChar(10) char in your string. What about string functions in C#, well, they are not so good as in, for example, VB, so I prefer to use a string as an array of chars. For ex:
string s = "Test";
then: s[0] = 'T'; etc...
So just use loops, it should be very easy.
CU
 
Oh, I forgot, that's C, so you can just use escape sequence '/n' for a new line.
 
I would use Split('\n') to create an array containing all the strings. You can then pick out easily the one you want.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top