ExtensionMethod.NET Home of 820 C#, Visual Basic, F# and Javascript extension methods

toDecimal

Object to decimal?

Source

private decimal? ToDecimal(Object obj)
		{
			decimal result = 0;
			if (obj == null) return null;

			if (decimal.TryParse(obj.ToString(), out result))
				return result;
			return null;
		}

Example

ToDecimal(row["col"]

Author: Tomcat

Submitted on: 6 sep 2016

Language: C#

Type: Object to decimal?

Views: 1625