C#获取字符串后几位数的方法

本文实例讲述了C#获取字符串后几位数的方法。分享给大家供大家参考。具体实现方法如下:

#region 获取后几位数 public string GetLastStr(string str,int num)
/// 
/// 获取后几位数
/// 
/// 要截取的字符串
/// 返回的具体位数
/// 返回结果的字符串
public string GetLastStr(string str, int num)
{
  int count = 0;
  if (str.Length > num)
  {
 count = str.Length - num;
 str = str.Substring(count, num);
  }
  return str;
}
#endregion

希望本文所述对大家的C#程序设计有所帮助。

你可能感兴趣的:(C#获取字符串后几位数的方法)