asp.net - Trimming down a string in C# code-behind -


i have line in code-behind:

lblaboutme.text = (dt1["userbody"].tostring()); 

no problems. now, want should beginning of paragraph , elipse. so, instead of being:

please read hate wasting time people don't. if have issue muslim's please move on not. used practice islam , while no longer still respect , hate ignorance people show following media or stigma instead of experiencing or talking muslim's educate it. referring no drug policy later in profile, yes, pot/marijuana counts drug , no me please move on. know follows makes me seem cold quite warm , loving, devoted right one, tired of being played , taken granted/ advantage of. people lie soooo , ignore of not want. have been told many times on here seek much.

we want take first, say, 100 characters , follow ellipse. so, like:

please read hate wasting time people don't. if have issue muslim's please move on not. used practice islam , while no longer still respect , hate ignorance people show following media or stigma instead of experiencing or talking muslim's educate ...

how can in code-behind? have feeling it's pretty easy (because easy in access), i'm still new language.

use length determine string length, use substring take of (100 chars) if long:

string aboutme = dt1["userbody"] != null ? dt1["userbody"].tostring() : ""; //just in case dt1["userbody"] null lblaboutme.text = aboutme.length > 100 ? aboutme.substring(0,100) + "..." : aboutme; 

Comments