using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Azylee.Core.DataUtils.StringUtils { /// /// String类型扩展方法 /// public static class StringExtension { private static void Test() { string s = "Hello Extension Methods"; int i = s.WordCount(); s.Ok(); } /// /// 判断字符串 非null、""、空格(Not NullOrWhiteSpace) /// /// /// public static bool Ok(this String s) { return Str.Ok(s); } public static int WordCount(this String str) { return str.Split(new char[] { ' ', '.', '?' }, StringSplitOptions.RemoveEmptyEntries).Length; } } }