namespace WMS.Util { /// /// 扩展 - 可空类型 /// public static partial class Extensions { /// /// 安全返回值 /// /// 可空值 public static T SafeValue(this T? value) where T : struct { return value ?? default(T); } /// /// 是否包含 /// /// 字串 /// 包含字串 /// public static bool ContainsEx(this string obj,string value) { if (string.IsNullOrEmpty(obj)) { return false; } else { return obj.Contains(value); } } /// /// 字串是否在指定字串中存在 /// /// 字串 /// 被包含字串 /// public static bool Like(this string obj, string value) { if (string.IsNullOrEmpty(value)) { return false; } else if (string.IsNullOrEmpty(obj)) { return false; } else { if (value.IndexOf(obj) != -1) { return true; } else { return false; } } } } }