Molecules 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Molecules --version 2.0.0
                    
NuGet\Install-Package Molecules -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Molecules" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Molecules" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Molecules" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Molecules --version 2.0.0
                    
#r "nuget: Molecules, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Molecules@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Molecules&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Molecules&version=2.0.0
                    
Install as a Cake Tool

Molecules:

  • Molecules is a class library targeting the .NETStandard 2.0 and 2.1, and is also available as a Nuget package.
  • Simply reference the library/package as preferred, and add the below using
using Molecules;

Elements:

  • Instances of the Element class represent chemical elements.
  • 118 static instance are provided on this class, allowing easy access to elements.
  • Element also implements IEquatable<Element> using property comparison.
var hydrogen = Element.H;
Console.WriteLine(hydrogen); 
// Output: 1 Hydrogen (H)

Element Collections:

  • The ElementCollection class implements ICollection<Element> but also provides indexers for easy access.
  • ElementCollection contains a static member ElementCollection.PeriodicTable which is an ElementCollection formed with the 118 elements mentioned above..
var hydrogen = ElementCollection.PeriodicTable["H"]; // Access by symbol
var oxygen = ElementCollection.PeriodicTable[8]; // Access by atomic number.
var carbon = ElementCollection.PeriodicTable[12.0107] // Access by atomic mass.
var nitrogen = ElementCollection.GetByName("Nitrogen"); // Note that this method is case insensitive.
Console.WriteLine(hydrogen);
Console.WriteLine(oxygen); 
Console.WriteLine(carbon); 
Console.WriteLine(nitrogen); 
// Output:
// 1 Hydrogen (H)
// 8 Oxygen (O)
// 6 Carbon (C)
// 7 Nitrogen (N)

Molecules:

  • The Molecule class is the core of the project.
  • It contains no public constructors, but does have static methods: Molecule.Parse() and Molecule.TryParse() for parsing strings containing chemical formulae.
  • The format of strings to be parsed is as follows:
    • The string may contain letters in either upper or lower case, digits and parentheses - "(" and ")".
    • The character after any parentheses must be a digit or be upper case.
    • Nested parentheses are not yet supported.
  • By default, the parsing methods will use ElementCollection.PeriodicTable as a reference, but there are overloads to allow users to define an ElementCollection to use instead.
var water = Molecule.Parse("H2O");
Console.WriteLine(water.Mass);
// Output: 18.01528
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net5.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.0.0 176 2/3/2025
4.0.0 675 12/28/2021
3.0.0 549 4/25/2021
2.0.0 576 11/22/2020
1.0.0 663 7/16/2020

Migrate to .NET 5.0