Very new to C#. I'm a workhorse but one step at a time. I'm trying to make simple program. "What is out the door cost of an item that has sales tax?" You should enter the program and then type the amount of the purchase. Then the purchase amount is multiplied by 1.07 to get the actual total. This is very simple and not much use to anyone who doesn't have a calculator, but how do you get the entered data (a string) converted to a number (a float) The ability to take strings and assign the value to a number is very important to me.

10 Years
Discussion Span
Last Post by Ramy Mahrous

To convert string to float

string numberAsString = "50.5";
float floatingPointNumber = float.Parse(numberAsString);

To convert string to integer

string numberAsString = "50";
int number = int.Parse(numberAsString);
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.