Split Text
///
/// Split text without messing the words
///
/// input string
/// desired length
///output string
public string SplitTextFromEnd(string str, int len)
{
string rez=str;
if(len==0 len >=str.Length)
return rez;
int i=0;
string[] words=str.Split(' ');
rez="";
while(len>rez.Length)
{
rez+=words[i++]+' ';
}
rez=rez.Substring(0,rez.Length-1-words[i-1].Length);
rez+=" ...";
return rez;
}
/// Split text without messing the words
///
/// input string
/// desired length
///
public string SplitTextFromEnd(string str, int len)
{
string rez=str;
if(len==0 len >=str.Length)
return rez;
int i=0;
string[] words=str.Split(' ');
rez="";
while(len>rez.Length)
{
rez+=words[i++]+' ';
}
rez=rez.Substring(0,rez.Length-1-words[i-1].Length);
rez+=" ...";
return rez;
}

0 Comments:
Post a Comment
<< Home