C# 常用扩展方法

2021-05-29 03:03

阅读:903

标签:splay   int   sys   现在   assembly   comm   内容   tty   display   

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CommonSD
{
    public static class MyExtensions
    {
        public static void DisplayDefiningAssembly(this object obj) // 
        {
            //Console.WriteLine("{0} lives here:=> {1}\n", obj.GetType().Name, Assembly.GetAssembly(obj.GetType()).GetName().Name);
        }

        public static int ReverseDigits(this int i)
        {
            // 把int翻译为string然后获取所有字符
            char[] digits = i.ToString().ToCharArray();
            // 现在反转数组中的项
            Array.Reverse(digits);
            // 放回string
            string newDigits = new string(digits);
            // 最后以int返回修改后的字符串
            return int.Parse(newDigits);
        }

        public static int ToInt(this string value)
        {
            return int.Parse(value);
        }
    }
}

以后内容再做补充

C# 常用扩展方法

标签:splay   int   sys   现在   assembly   comm   内容   tty   display   

原文地址:https://www.cnblogs.com/zhang1f/p/11106081.html


评论


亲,登录后才可以留言!