.Net2.0实现扩展方法

来源:互联网 发布:姓名大战 源码 编辑:程序博客网 时间:2024/06/13 14:36
    public class ExtensionAttribute : Attribute { }
    /// <summary>
    /// 扩展String方法
    /// </summary>
    public static class StringExtension
    {
        public static int ToInt(this string str)
        {
            int result = 0;
            int.TryParse(str, out result);
            return result;
        }
    }