How to cut some character from the string to make "caption" for news
Hj All. I have a question that's i want to cut or separate the string to make a caption for my news or something.I mean i have a paragrap and i want to take some character from paragrap to make a caption for my article or news.Notherwise that's a brief of paragrap.Someone help me about that!Thanks .
Manoj SevdaPosted Nov 12, 2011, 1:25 AM
string para = "balabalabalabala"
if (lblPara.Text.Length > 50)
lblPara.Text = para.Substring(0, 50) + ".. ";
else
lblPara.Text = para.Text;
Sam HobbsPosted Nov 8, 2011, 1:37 PM
If it were me, I would use a console program to write and test the code, and then copy the code into my main program. You will need a little time to get it working correctly and you will learn from the experience. Someone might write all the code for you, but I think it will be more educational for you if you learn from doing it yourself.
Dipal ChoksiPosted Nov 8, 2011, 10:56 AM
http://nickstips.wordpress.com/2010/02/12/c-truncate-a-string-at-the-end-of-a-word/
you can also use string.split and then use logic to count the characters.
Javeed M ShaikhPosted Nov 8, 2011, 10:55 AM
^(\w+\b.*?){10}
viet vo quocPosted Nov 8, 2011, 9:58 AM
Javeed M ShaikhPosted Nov 8, 2011, 9:27 AM
if you just want to cut some characters from a string, try this..
string MyString = "Hello Cut Me!";
Console.WriteLine(MyString.Remove(5,3));
it should remove the "Cut" word.