C# 类参数列表不确定

4381人阅读 2021/3/10 17:30 总访问:651583 评论:0 收藏:0 手机
分类: Csharp

 不确定参数数目使用 params ,再用数组接收

 
        //定义方法的时候参数类型是确定的
        public static string Strformat(this string str, string a, int b, string c)
        {
            return String.Format(str, a, b, c);
        }
        //改过之后
         public static string Strformat<T>(this string str, params object[] items)
        {
            return String.Format(str, items);
        }


评价
脚踏实地,一步一个脚印
排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2024TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
欢迎加群交流技术