using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ExtraMethod
{
//抽象出静态StringHelper类
public static class StringHelper
{
//抽象出来的将字符串第一个字符大写,从第一个到第len个小写,其他的不变的方法
public static string ToPascal(string s,int len)
{
return s.Substring(0, 1).ToUpper() + s.Substring(1, len).ToLower() + s.Substring(len + 1);
}
}
class Program
{
static void Main(string[] args)
{
string s1 = "aSDdAdfGDFSf";
string s2 = "sbfSDffsjG";
Console.WriteLine(StringHelper.ToPascal(s1,3));
Console.WriteLine(StringHelper.ToPascal(s2, 5));
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ExtraMethod
{
class Program
{
static void Main(string[] args)
{
string s1 = "aSDdAdfGDFSf";
string s2 = "sbfSDffsjG";
Console.WriteLine(s1.ToPascal(3));
Console.WriteLine(s2.ToPascal(5));
}
}
//扩展类,只要是静态就可以
public static class ExtraClass
{
//扩展方法--特殊的静态方法--为string类型添加特殊的方法ToPascal
public static string ToPascal(this string s, int len)
{
return s.Substring(0, 1).ToUpper() + s.Substring(1, len).ToLower() + s.Substring(len + 1);
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有