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.

Recommended Answers

All 3 Replies

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);

Thank you Ramy.

You're welcome, thanks for your nice reputation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.