2

如何将整数和字符串连接成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;
4

3 回答 3

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;

正是如果你有这个要求,那么我会建议第一个。

于 2013-05-27T09:02:21.213 回答
2

.Interval需要一个双倍,你能不能只将 int 转换为双精度?

chart1.ChartAreas[0].AxisX.LabelStyle.Interval = Convert.toDouble(a);
于 2013-05-27T09:03:06.230 回答
1

而不是int a;double a;和:

chart1.ChartAreas[0].AxisX.LabelStyle.Interval = a;
于 2013-05-27T09:19:32.683 回答