C# DELL机器根据服务编号计算快速服务代码

private static string StandardSerial = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/// <summary>
/// 计算快速服务代码
/// </summary>
/// <param name="serialNo">服务编号</param>
/// <returns></returns>
public static string GetServiceCode(string serialNo)
{
   if (serialNo.Length != 7) return string.Empty;
   serialNo = serialNo.ToUpper();
   Int64 ServiceCode = 0;

   for (int i = 0; i < 7; i++)
   {
      ServiceCode += Convert.ToInt64(Math.Pow(36, 6 - i) * StandardSerial.IndexOf(serialNo[i]));
   }

   return ServiceCode.ToString();
}

 

posted @ 2013-03-12 13:22  逍遥子k  阅读(537)  评论(1编辑  收藏  举报