Console.WriteLine(s.ToUpper());//转换成大写 Console.WriteLine(s.ToLower());//转换成小写
public static void fanxiang(string s)
{
char[] arrey = s.ToCharArray();
StringBuilder s1 = new StringBuilder("");
for (int i = arrey.Length - 1; i >= 0; i--)
{
s1.Append(Convert.ToString(arrey[i]));
}
Console.WriteLine("反向字符串为{0}",s1);
}
public static void pipei(string s)
{
int count = 0;
int i;
Console.WriteLine("请输入短字符串");
string s2 = Console.ReadLine();
while ((i=s.IndexOf(s2)) >= 0)
{
count++;
s = s.Substring(i + s2.Length);
}
Console.WriteLine("字符串中出现了{0}次{1}", count, s2);
}
public static void zzpipei(string s)
{
Console.WriteLine("请输入正则表达式");
string zz = Console.ReadLine();
Regex re = new Regex(zz);
string s2 = "";
if (re.IsMatch(s))
{
Console.WriteLine("匹配成功");
MatchCollection mc = re.Matches(s);
foreach (Match ma in mc)
{
s2 += ma.Value;
s2 += ("\r\n");
}
Console.WriteLine("一行为一个匹配结果");
Console.WriteLine(s2);
}
else
{ Console.WriteLine("无匹配结果"); }
}
public static void basejiami(string s)
{
byte[] bytes = Encoding.Default.GetBytes(s);
Console.WriteLine("字符串base64加密为{0}", Convert.ToBase64String(bytes));
}
public static void basejiemi(string s)
{
byte[] bytes = Convert.FromBase64String(s);
Console.WriteLine("字符串base64解密为{0}", Encoding.Default.GetString(bytes));
}
public static void rotjm(string s)
{
string jmzf = "";//解密加密后的字符串
char[] arrey = s.ToCharArray();
Console.WriteLine("字符串长度为{0}", arrey.Length);
for (int i = 0; i < arrey.Length; i++)
{
int zfcode = (int)arrey[i];
if (zfcode >= 97 && zfcode <= 109)
zfcode = zfcode + 13;
else if (zfcode >= 110 && zfcode <= 122)
zfcode = zfcode - 13;
else if (zfcode >= 65 && zfcode <= 77)
zfcode = zfcode + 13;
else if (zfcode >= 78 && zfcode <= 90)
zfcode = zfcode - 13;
jmzf = jmzf + (char)zfcode;
}
Console.WriteLine("结果为{0}", jmzf);
}
public static void thzf(string s)
{
Console.WriteLine("请输入想要被替换的字符串");
string str1 = Console.ReadLine();
Console.WriteLine("请输入想要替换成的字符串");
string str2 = Console.ReadLine();
Console.WriteLine(s.Replace(str1, str2));
}
public static void md5jm(string s)
{
MD5 md5 = new MD5CryptoServiceProvider();
//将字符编码为字节序列
byte[] data = System.Text.Encoding.Default.GetBytes(s);
byte[] md5data = md5.ComputeHash(data);
md5.Clear();
//遍历加密数组,加密字节,该方法为32位加密
string str = "";
for (int i = 0; i < md5data.Length; i++)
{
str += md5data[i].ToString("x").PadLeft(2, '0');
}
Console.WriteLine("加密结果为{0}",str);
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有