相当简单的C#函数实现代码片断,按照最小行长度分行和断行(会超过最小行长度),曾用于自动给太长的Winform Tooltip断行。

private string MultiplineString(string instr, int line_length)
{
    
string remain = instr, multi_line="";
    
while(remain.Length > line_length)
    {
        
int space_pos = remain.IndexOf(' ', line_length);
        
if (space_pos == -1)
            
break;
        multi_line 
+= remain.Substring(0, space_pos) + "\r\n";
        remain 
= remain.Substring(space_pos + 1);
    }
    
return multi_line + remain;
}

相关文章:

  • 2021-11-11
  • 2021-12-31
  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-13
  • 2021-09-11
  • 2022-01-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案