如何将整数和字符串连接到var?
int a; int x=2; int y=7200;
a=x*y;
var B=a+"D"; // How to concatenate this to turn it 14400D
// I need use this in the code that changes the AxisX.LabelStyle.Interval.
// We can not use string concatenation here.
chart1.ChartAreas[0].AxisX.LabelStyle.Interval=B;
答案 0 :(得分:2)
通过查看您的代码。我认为你似乎需要这个代码。?
int a; int x = 2; int y = 7200;
a = x * y;
var B = a.ToString() + "D";
chart1.ChartAreas[0].AxisX.LabelStyle.Interval = B;
OR
int a; int x = 2; int y = 7200;
a = x * y;
String aValue = a.ToString() + "D";
var B = aValue;
chart1.ChartAreas[0].AxisX.LabelStyle.Interval = B;
如果您的要求正确,那么我会先建议。
答案 1 :(得分:2)
.Interval
需要一倍,你能不能将int转换为双倍?
chart1.ChartAreas[0].AxisX.LabelStyle.Interval = Convert.toDouble(a);
答案 2 :(得分:1)
而不是int a;
写double a;
和:
chart1.ChartAreas[0].AxisX.LabelStyle.Interval = a;