have the flowing C++ code:
CString info, info2;
info.Format("%2d", Value[i]);
info2.Format("%4.1f", Value[j]);
want to have the equivalent code in C#
how to do it?
have the flowing C++ code:
CString info, info2;
info.Format("%2d", Value[i]);
info2.Format("%4.1f", Value[j]);
want to have the equivalent code in C#
how to do it?
Code ported to C#:
String info;
String info2;
info = String.Format("{0,2:D}", Value[i]);
info2 = String.Format("{0,6:0.0}", Value[j]);
6 is used for aligning the string 4 digits plus decimal point plus decimal digit.
NOTE take care of the current Culture used, you might get ,
instead of .
for some Cultures.