I am currently making a tax program (study project) that read in a CSV file and generates a list of people and account balances, i need to round down 2 decimal places from one text box and add them up in another text box. my code attached tell me i cannot use " * " how do i times a decimal with 0.1? and if i am doing this wrong let me know, cheers!
public partial class Form1 : Form
{
//CSV ARRAY LISTS
List<string> fullName = new List<string>();
List<string> accBalance = new List<string>();
int currentItem;
int index;
int counter = 0;
decimal interestBalance = 0;
decimal result;
decimal interestRemainder = 0;
double round = 0.1;
private void interestBalanceBox_TextChanged(object sender, EventArgs e)
{
interestRemainder = decimal.Parse(interestBalanceBox.Text);
interestRemainder = Math.Truncate(0.1 * interestRemainder) / 100;
interestRemainderBox.Text = interestRemainder.ToString();
}
the program we are meant to represent is this one here! any help would be much appreciated.
interestRemainder = Math.Truncate((decimal)0.1 * interestRemainder) / 100;
You need to cast the 0.1 to the same type as the other operand