Copy Code code as follows:
Two practical ways to intercept strings (wrap more than a certain length)
///
Intercepts a string, without limiting the length of the string
///
String to be intercepted
The length of each line, more than the length of the line wrap
///
public string Cutstr (string Str,int len)
{string s= "";
for (int i=0;i 11 {
int r= i% Len;
int last = (str. Length/len) *len;
if (i!=0 && i<=last)
{
if (r==0)
{
S+=str. Substring (I-len,len) + "";
}
}
else if (i>last)
{
S+=str. Substring (i-1);
Break
}
}
return s;
}
///
Intercepts the string and restricts the string length more than the given length + ...
///
String to be intercepted
The length of each line, more than the length of the line wrap
Maximum length of output string
///
public string Cutstr (string str,int len,int max)
{
String S= "";
String Sheng= "";
if (str. Length >max)
{
Str=str. Substring (0,max);
Sheng= "";
}
for (int i=0;i 53 {
int r= i% Len;
int last = (str. Length/len) *len;
if (i!=0 && i<=last)
{
if (r==0)
{
S+=str. Substring (I-len,len) + "";
}
}
else if (i>last)
{
S+=str. Substring (i-1);
Break
}
}
return S+sheng;
}