.NET Fiddle

CSharp · Console

/Program.cs

using System;
					
public class Program
{
	public static void Main()
	{
		ParseAndPrint( 1.0M );
		ParseAndPrint( 2.2M );
		ParseAndPrint( null );
	}
	
	public static void ParseAndPrint( decimal ? dec )
	{
		int? parseAppliedAmount( decimal? d ) {
			if ( d.HasValue )
			{
				return Convert.ToInt32( Math.Round(d.Value, 0) );
			}
			else
			{
				return null;
			}
		}
		
		/* This is the local/ternary function I want to use, but it does not compile
		int? parseAppliedAmountTernary( decimal? d ) { 
			d.HasValue ? return Convert.ToInt32( Math.Round(d.Value, 0) ) : return null;
		}
		*/
		
		int? intAmount = parseAppliedAmount( dec );
		string output = intAmount.HasValue ? intAmount.Value.ToString() : "(null)";

		Console.WriteLine( "Parsed int amount: " + output );
	}
}
;