Putting aside the invalid syntax/compiler error from your method calls in your code, I suspect you're building the string but can't get the leading 0
in front of digits 0-9. So when Xmonth
and Xhour
are less than 10, your string is being built as "csv_1_1"
instead of your intended "csv_01_01"
.
To instruct the ToString
method to include a leading zero when needed, you can supply a custom numeric format string "00"
(see the first entry in the link for "Zero placeholder").
Try using Xmonth.ToString("00")
and Xhour.ToString("00")
:
Monitor.malyt.m3h = Convert.ToDouble(confg.csv["csv_" +
Xmonth.ToString("00") + "_" +
Xhour.ToString("00")]);
This will output the values of Xmonth
and Xhour
with a single leading zero where needed.