using System; using System.Collections.Generic; using System.Text; namespace WCS.PLC.Common { public class ConvertHelper { private int? TryParseInt(string value) { var i = 0; if (!int.TryParse(value, out i)) { return null; } return i; } // (DB_TypeEnum)(DB_TypeEnum)Enum.ToObject(typeof(DB_TypeEnum), DB.DB_TYPE); public T? TryParseEnum(string value) where T : struct, IConvertible { var i = TryParseInt(value); if (!i.HasValue) { return null; } return (T)(object)i.Value; } } }