I wanted to make a small program, where i essentially have a lot of doubles for the atom mass for each atom. I want to be able to write a molecule formula into a textbox, whereafter the program should be able to calculate the molar mass, however, i dont know how i can cut the string from the textbox, so that for instance i can get from inserting "NaCl" into the textbox, the value of my Na double plus the value of my Cl double.
public partial class Form1 : Form
double H = 1.00794;
double He = 4.002602;
double Li = 6.941;
double Be = 9.012182;
These are just all my doubles, now what i want a button to do:
private void button1_Click(object sender, EventArgs e)
//take the different atoms in the molecule formula from a textbox,
//get the value of all those doubles, and add them all together to get
//a final value, for instance: NaCl = Na + Cl = 22.98976928 + 35.453 = 58.44276928
Also, i want to be able to write H2SO4, which essentially is H*2 + S + O*4, how would i go about doing that?
Thank you in advance