Closed HuanLab closed 3 years ago
Use MolecularFormulaManipulator
class like below. MolecularFormula
class has only basic functionality.
using NCDK;
using NCDK.Tools.Manipulator;
using System;
namespace ConsoleApp6
{
class Program
{
static void Main(string[] args)
{
string formula = "C6H6";
IMolecularFormula mf = MolecularFormulaManipulator.GetMolecularFormula(formula);
double mass = MolecularFormulaManipulator.GetMass(mf, MolecularWeightTypes.MolWeight);
Console.WriteLine($"{formula} mass = {mass}");
}
}
}
Above outputs below.
C6H6 mass = 78.11205990368275
Thank you so much, this solved my problem!
Hi,
How can I generate a MolecularFormula object from a formula string (eg. C6H6). The default constructor seems to create an empty object.
Thanks,
Tao