SubString
string old = "80.57K";
RemoveCharfromString(old);
public static void RemoveCharfromString(string old)
{
if (!(string.IsNullOrEmpty(old)))
{
Console.WriteLine(old.Replace("K", ""));
Console.WriteLine(old.Remove(old.LastIndexOf("K"),1));
Console.WriteLine(old.Substring(0, old.LastIndexOf("K")));
}
}
static void Main(string[] args)
{
String old = "80.57K";
Console.WriteLine(RemoveCharfromString(old));
Console.ReadLine();
}
public static String RemoveCharfromString(string old)
{
if (!(string.IsNullOrEmpty(old)))
{
String newStr = old.Replace("K", "");
double result = 0.0;
if (Double.TryParse(newStr, out result))
{
return (result * 1000).ToString();
}
}
return old;
}
是需要去掉“K”之后乘1000么?