i need to put in my label something like "x rub | y%" but label ignores the rest of text after the x. when the label gets "0" value, it works as i want it to, i.e. "0$. | 0%", but whenever the value isnt 0, it only displays "read_cat"'s value ("2000"). Thank you in advance.
System.IO.StreamReader reading2 = File.OpenText("categories\\clothes.txt");
read_cat1 = Convert.ToString(File.ReadAllText("categories\\clothes.txt"));
clothes_percentage.Text = Convert.ToString(read_cat1) "$ | "
Convert.ToString(Math.Round(Convert.ToDouble(read_cat1) * 100 / salary, 2)) "%";
reading2.Close();
CodePudding user response:
My guess is that your file contains a linebreak after the actual value. Use the Trim() method to remove linebreaks and other whitespace from the string you read from the file.
string read_cat1 = File.ReadAllText("categories\\clothes.txt");
read_cat1 = read_cat1.Trim();
clothes_percentage.Text = read_cat1 "$ | "
Math.Round(Convert.ToDouble(read_cat1) * 100 / salary, 2) "%";