我怎么给Break In Long String [英] How I give Break In Long String

查看:56
本文介绍了我怎么给Break In Long String的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

string longString =
     "Weather Information " +
     "GEO Potentail Height (Gpm) : " + weatherinfo[0] +
     "Pressure (pa) : " + weatherinfo[1] +
     "Sea Tempreature (K) : " + weatherinfo[2] +
     "Significant Height of Wind : " + weatherinfo[3] +
     "waves & swell(m) : " + weatherinfo[3] +
     "Wind Speed(m/s)/Direction(°) : " + str[0] + str[1]  ;
          // str1 = weatherinfo[0] = "-";
           return longString;

>



我试图通过警报框中的中断返回此信息

推荐答案

使用换行符。

Use the new line character.
string longString =
     "Weather Information " + "\n" +
     "GEO Potentail Height (Gpm) : " + weatherinfo[0] + "\n" +
     "Pressure (pa) : " + weatherinfo[1] + "\n" +
     "Sea Tempreature (K) : " + weatherinfo[2] + "\n" +
     "Significant Height of Wind : " + weatherinfo[3] + "\n" +
     "waves & swell(m) : " + weatherinfo[3] + "\n" +
     "Wind Speed(m/s)/Direction(°) : " + str[0] + str[1]  ;


您可以准备一个模板用于String.Format:
You can prepare a template to use with String.Format:
private const WeatherDataTemplateString =
      @"Weather Information
      GEO Potentail Height (Gpm) : {0}
      Pressure (pa) : {1}
      Sea Tempreature (K) : {2}
      Significant Height of Wind : {3}
      waves & swell(m) : {4}
      Wind Speed(m/s)/Direction(°) : {5}{6}";

;并称之为像这样:

textBox1.Text = string.Format(WeatherDataTemplateString, 1, 2, 3, 4, 5, 6, 7);

只需使用'WeatherInfo和'str数组数据填写项目列表。

Just use your 'WeatherInfo and 'str array data to fill out the item list.


 string report =
"             Weather Information\\n" +
"GEO Potentail Height (Gpm) :" + weatherinfo[0] +
"\\nPressure (pa) : " + weatherinfo[1] +
"\\nSea Tempreature (K) : " + weatherinfo[2] +
"\\nSignificant Height of Wind : " + weatherinfo[3] +
"\\nwaves & swell(m) : " + weatherinfo[3] +
"\\nWind Speed(m/s)/Direction(°) : " + str[0] + "/" + str[1];

      return report;







我们可以这样做


这篇关于我怎么给Break In Long String的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆