سؤال

How to concatenate integer and string into 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;
هل كانت مفيدة؟

المحلول

.Interval takes a double, could you not just convert the int to a double instead?

chart1.ChartAreas[0].AxisX.LabelStyle.Interval = Convert.toDouble(a);

نصائح أخرى

By Looking your code. I think you need this code it seems.?

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;

Exactly If your requirement this, then I would suggest first one.

Instead of int a; write double a; and:

chart1.ChartAreas[0].AxisX.LabelStyle.Interval = a;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top