打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
C# Left, Right and Mid函数
  1. class LeftRightMid  
  2. {  
  3.     static void Main(string[] args)  
  4.     {  
  5.         string myString = "This is a string";  
  6.         Console.WriteLine(Left(myString, 4));  
  7.         Console.WriteLine(Right(myString, 6));  
  8.         Console.WriteLine(Mid(myString, 5, 4));  
  9.         Console.WriteLine(Mid(myString, 5));  
  10.         Console.ReadLine();  
  11.     }  
  12.     public static string Left(string param, int length)  
  13.     {  
  14.         string result = param.Substring(0, length);  
  15.         return result;  
  16.     }  
  17.     public static string Right(string param, int length)  
  18.     {  
  19.         string result = param.Substring(param.Length - length, length);  
  20.         return result;  
  21.     }  
  22.     public static string Mid(string param, int startIndex, int length)  
  23.     {  
  24.         string result = param.Substring(startIndex, length);  
  25.         return result;  
  26.     }  
  27.     public static string Mid(string param, int startIndex)  
  28.     {  
  29.         string result = param.Substring(startIndex);  
  30.         return result;  
  31.     }  
  32.   
  33. }  


 

 

 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
数据结构与算法:13 字符串与整数集合
C#生成唯一值的方法汇总
C# 字符串(String) | 菜鸟教程
C#优化字符串操作
c# – 将字符串分隔到不在集合字典中的列表中
一个.Net加密解密类-程序开发-红黑联盟
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服