using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GreenTree.Nachtragsmanagement.Core.Helper
{
    public static class MiscHelper
    {
        /// <summary>
        /// Trys to parse a string to valid integer and returns NULL if it fails
        /// </summary>
        /// <param name="item">String value.</param>
        /// <returns>Parsed string.</returns>
        public static int? TryGetInt(this string item)
        {
            if (String.IsNullOrEmpty(item)) return null;

            int i;

            var success = int.TryParse(item, out i);

            return success ? (int?)i : (int?)null;
        }
    }
}
