123456789101112131415161718192021222324252627282930 |
- 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<T>(string value) where T : struct, IConvertible
- {
- var i = TryParseInt(value);
- if (!i.HasValue)
- {
- return null;
- }
- return (T)(object)i.Value;
- }
- }
- }
|