C# - String Parse after so many characters and then "..more"
Posted on 2012-04-10
I have a datatable with rows of course and I am just currently adding each column value to a string variable as below:
foreach (DataRow row in dt.Rows)
strUniqueValues += row["MyColumn"].ToString() + ",";
What I was doing was if there was <= 3 rows then I just appended to the string otherwise in an else statement I was just doing a for loop 0-2 then I have a linkbutton that says "and 12 others" for example.
What I want to do is somehow have like say 300 characters max then cutoff and say "and 12 others" for example. But I need it to be a clean cutoff where I show each whole string value then get a count of the remaining for the "and + cntremain + others".
Anyone know how I can do this?