当前位置: 首页>>代码示例>>C#>>正文


C# ChemicalFormula.Remove方法代码示例

本文整理汇总了C#中ChemicalFormula.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# ChemicalFormula.Remove方法的具体用法?C# ChemicalFormula.Remove怎么用?C# ChemicalFormula.Remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ChemicalFormula的用法示例。


在下文中一共展示了ChemicalFormula.Remove方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ChemicalFormulaExamples

        /// <summary>
        /// Basic overview of how chemical formulas can be used and modified
        /// </summary>
        private static void ChemicalFormulaExamples()
        {
            Console.WriteLine("**Chemical Formula Examples**");

            // Simple chemical formula creation
            ChemicalFormula formula1 = new ChemicalFormula("C2H3NO");
            WriteFormulaToConsole(formula1);

            // Input order does not matter
            ChemicalFormula formula2 = new ChemicalFormula("NH3C2O");
            WriteFormulaToConsole(formula2);

            // Formulas are identicial if they have the exact same type of elements and count
            Console.WriteLine("Are {0} and {1} equivalent? {2}", formula1, formula2, formula1.Equals(formula2));

            // You can modify exisiting chemical formulas in many ways.
            // You can add a chemical formula to a chemical formula
            formula1.Add(formula2);
            WriteFormulaToConsole(formula1);
            Console.WriteLine("Are {0} and {1} equivalent? {2}", formula1, formula2, formula1.Equals(formula2));

            // You can completely remove an element from a chemical formula
            formula1.Remove("C");
            WriteFormulaToConsole(formula1);

            // Even negative values are possible if not physically possible
            formula1.Remove(formula2);
            WriteFormulaToConsole(formula1);

            // Implicit arithmetic is also possible (supports +, -, and *)
            ChemicalFormula formula3 = formula2 - formula1;
            WriteFormulaToConsole(formula3);
            ChemicalFormula formula4 = formula3 + formula1;
            WriteFormulaToConsole(formula4);
            ChemicalFormula formula5 = formula2*5;
            WriteFormulaToConsole(formula5);

            // Formulas consist of a dictionary of isotopes and count, and by default, the most common (abundant) isotope of an element
            // is included (i.e. Carbon 12 instead of Carbon 13). You can explicitly state that you want another isotope in a chemical formula
            // by this notation: <Element Symbol>{<Mass Number>} (e.g. C{13}, N{15}, etc..)

            formula1 = new ChemicalFormula("C2C{13}2H3NO");
            formula2 = new ChemicalFormula("C4H3NO");

            WriteFormulaToConsole(formula1);
            WriteFormulaToConsole(formula2);

            Console.WriteLine("Are {0} and {1} equivalent? {2}", formula1, formula2, formula1.Equals(formula2));

            // No need to specify the mass number of the most abundant isotope for an element
            formula3 = new ChemicalFormula("C{12}2C2H3NO");
            formula4 = new ChemicalFormula("C4H3NO");
            Console.WriteLine("Are {0} and {1} equivalent? {2}", formula3, formula4, formula3.Equals(formula4));
        }
开发者ID:dbaileychess,项目名称:CSMSL,代码行数:57,代码来源:Examples.cs

示例2: RemoveZeroIsotopeFromFromula

        public void RemoveZeroIsotopeFromFromula()
        {
            ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
            ChemicalFormula formulaB = new ChemicalFormula("C2H3NO");

            formulaA.Remove(Element.PeriodicTable["H"][1], 0);

            Assert.AreEqual(formulaA, formulaB);
        }
开发者ID:kmmbvnr,项目名称:CSMSL,代码行数:9,代码来源:ChemicalFormulaTestFixture.cs

示例3: RemoveNullIsotopeFromFromula

        public void RemoveNullIsotopeFromFromula()
        {
            ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
            ChemicalFormula formulaB = new ChemicalFormula("C2H3NO");

            formulaA.Remove(NullIsotope);

            Assert.AreEqual(formulaA, formulaB);
        }
开发者ID:kmmbvnr,项目名称:CSMSL,代码行数:9,代码来源:ChemicalFormulaTestFixture.cs

示例4: RemoveNonExistantIsotopeFromFromula

        public void RemoveNonExistantIsotopeFromFromula()
        {
            ChemicalFormula formulaA = new ChemicalFormula("C2H5NO2");
            ChemicalFormula formulaB = new ChemicalFormula("Fe");
            ChemicalFormula formulaC = new ChemicalFormula("C2H5Fe-1NO2");

            formulaA.Remove(formulaB);

            Assert.AreEqual(formulaA, formulaC);
        }
开发者ID:kmmbvnr,项目名称:CSMSL,代码行数:10,代码来源:ChemicalFormulaTestFixture.cs

示例5: RemoveIsotopeFromFromulaEquality

        public void RemoveIsotopeFromFromulaEquality()
        {
            ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
            ChemicalFormula formulaB = new ChemicalFormula("C2H3O");

            formulaA.Remove("N", 1);

            Assert.AreEqual(formulaA, formulaB);
        }
开发者ID:kmmbvnr,项目名称:CSMSL,代码行数:9,代码来源:ChemicalFormulaTestFixture.cs

示例6: RemoveFormulaFromFromula

        public void RemoveFormulaFromFromula()
        {
            ChemicalFormula formulaA = new ChemicalFormula("C2H5NO2");
            ChemicalFormula formulaB = new ChemicalFormula("H2O");
            ChemicalFormula formulaC = new ChemicalFormula("C2H3NO");

            formulaA.Remove(formulaB);

            Assert.AreEqual(formulaA, formulaC);
        }
开发者ID:kmmbvnr,项目名称:CSMSL,代码行数:10,代码来源:ChemicalFormulaTestFixture.cs

示例7: RemoveEmptyFormulaFromFromula

        public void RemoveEmptyFormulaFromFromula()
        {
            ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
            ChemicalFormula formulaB = new ChemicalFormula("C2H3NO");

            formulaA.Remove(EmptyFormula);

            Assert.AreEqual(formulaA, formulaB);
        }
开发者ID:kmmbvnr,项目名称:CSMSL,代码行数:9,代码来源:ChemicalFormulaTestFixture.cs

示例8: RemoveElementCompletelyFromFromulaWithHeavyIsotope

        public void RemoveElementCompletelyFromFromulaWithHeavyIsotope()
        {
            ChemicalFormula formulaA = new ChemicalFormula("C2C{13}H3NO");
            ChemicalFormula formulaB = new ChemicalFormula("H3NO");

            formulaA.Remove(Element.PeriodicTable["C"]);

            Assert.AreEqual(formulaA, formulaB);
        }
开发者ID:kmmbvnr,项目名称:CSMSL,代码行数:9,代码来源:ChemicalFormulaTestFixture.cs

示例9: RemoveElementCompletelyFromFromulaBySymbol

        public void RemoveElementCompletelyFromFromulaBySymbol()
        {
            ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
            ChemicalFormula formulaB = new ChemicalFormula("C2NO");

            formulaA.Remove("H");

            Assert.AreEqual(formulaA, formulaB);
        }
开发者ID:kmmbvnr,项目名称:CSMSL,代码行数:9,代码来源:ChemicalFormulaTestFixture.cs

示例10: RemoveElementCompletelyFromFromula

        public void RemoveElementCompletelyFromFromula()
        {
            ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
            ChemicalFormula formulaB = new ChemicalFormula("C2NO");

            formulaA.Remove(Element.PeriodicTable["H"]);

            Assert.AreEqual(formulaA, formulaB);
        }
开发者ID:kmmbvnr,项目名称:CSMSL,代码行数:9,代码来源:ChemicalFormulaTestFixture.cs

示例11: RemoveZeroIsotopeFromFromula

        public void RemoveZeroIsotopeFromFromula()
        {
            ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
            ChemicalFormula formulaB = new ChemicalFormula("C2H3NO");

            formulaA.Remove(PeriodicTable.GetIsotope("H", 1), 0);

            Assert.AreEqual(formulaA, formulaB);
        }
开发者ID:dbaileychess,项目名称:CSMSL,代码行数:9,代码来源:ChemicalFormulaTestFixture.cs

示例12: RemoveNegativeIsotopeFromFromula

        public void RemoveNegativeIsotopeFromFromula()
        {
            ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
            ChemicalFormula formulaB = new ChemicalFormula("C2H5NO");

            formulaA.Remove(PeriodicTable.GetElement("H")[1], -2);

            Assert.AreEqual(formulaA, formulaB);
        }
开发者ID:dbaileychess,项目名称:CSMSL,代码行数:9,代码来源:ChemicalFormulaTestFixture.cs

示例13: RemoveIsotopeCompletelyFromFromula

        public void RemoveIsotopeCompletelyFromFromula()
        {
            ChemicalFormula formulaA = new ChemicalFormula("C2H3NO");
            ChemicalFormula formulaB = new ChemicalFormula("C2NO");

            formulaA.Remove(PeriodicTable.GetElement("H")[1]);

            Assert.AreEqual(formulaA, formulaB);
        }
开发者ID:dbaileychess,项目名称:CSMSL,代码行数:9,代码来源:ChemicalFormulaTestFixture.cs


注:本文中的ChemicalFormula.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。