私のアプリケーションは、C#.Netでコード化されたAsp.NetMVC3にあります。変換を取得するためにGoogleCurrencyConversionAPIを使用しています。
Google Currency Conversion APIFromCurrencyとToCurrencyの値と金額をコントローラーに 渡します。以下は私のC#コードです。
WebClient web = new WebClient();
string url = string.Format("http://www.google.com/ig/calculator?hl=en&q={2}{0}%3D%3F{1}", CurrenctCurr.ToUpper(), DestinationCurr.ToUpper(), TotCurrentPay);
string response = web.DownloadString(url);
Regex regex = new Regex("rhs: \\\"(\\d*.\\d*)");
Match match = regex.Match(response);
decimal rate = Convert.ToDecimal(match.Groups[1].Value);
オンラインでエラーが発生しました
decimal rate = Convert.ToDecimal(match.Groups[1].Value.ToString());
エラーは、入力文字列が正しい形式ではありません。内部例外はありません。
toString()に変換してみました
decimal rate = Convert.ToDecimal(match.Groups[1].Value.ToString());
また、文字列変数でmatchの値を取得してから、SubStringロジックを実行しようとしましたが、どちらも機能していません
string test = match.ToString();
test=test.substring(0,test.Indexof("""));
単一の引用符( ")があるので、"まで文字列の値を取得しようとしています。問題を解決する方法、または正しい方向で他に何を試すことができるかを提案します。