I am working on Windows Phone Application.
I need to concat two values which are integers and the result should be changed into float value.
For example, a = 120 and b = 3. Then result c = 120.3 which is float value. How to do this task?
I am working on Windows Phone Application.
I need to concat two values which are integers and the result should be changed into float value.
For example, a = 120 and b = 3. Then result c = 120.3 which is float value. How to do this task?
int a = 120;
int b = 3;
string s = a + "." + b;
float f = float.Parse(s);
How about using float.Parse
?
float value = float.Parse(string.Format("{0}.{1}", a.ToString(), b.ToString()));
You can try this sample code:
int a = 120;
int b = 3;
string c = a.ToString() + '.' + b.ToString();
float f = float.Parse(c,System.Globalization.CultureInfo.InvariantCulture);
How about using this shorter one:
float f = float.Parse(string.Concat(a, ".", b));
I would do is: dim FB = B * 0.1, C = A + FB as Float or as each part as string and S for string on your variables SC = SA +"." +SB And convert string to value this logic should work in most versions of C and BASIC and most likely other languages too