我创建一个C#Windows应用程序使用必发交换网络服务来显示当前体育市场的价格,我用了有没有人有使用betfair api的c#代码?
getmarketpricescompressed()
方法返回一个价格字符串,看起来像这样:
106093239~GBP~ACTIVE~0~1~~true~5.0~1343114432333~~N:7337~1~6992.56~2.16~~~false~~~~|2.16~1036.19~L~1~2.14~97.18~L~2~2.12~5.0~L~3~|2.18~467.36~B~1~2.2~34.12~B~2~2.22~162.03~B~3~:414464~2~102181.96~1.86~~~false~~~~|1.85~2900.33~L~1~1.84~1831.59~L~2~1.83~1593.73~L~3~|1.86~58.83~B~1~1.87~1171.77~B~2~1.88~169.15~B~3~
我不知道如何正确地解开这个字符串,现在我使用此代码:
GetMarketPricesCompressedReq price_req1 = new GetMarketPricesCompressedReq();
price_req1.header = header2;
price_req1.marketId = marketid_temp;
price_req1.currencyCode = "GBP";
GetMarketPricesCompressedResp price_resp = new GetMarketPricesCompressedResp();
price_resp = bfg2.getMarketPricesCompressed(price_req1);
//MessageBox.Show(price_resp.errorCode.ToString());
//richTextBox1.Text = "";
//richTextBox1.Text = price_resp.marketPrices;
string prices = price_resp.marketPrices;
richTextBox1.Text = price_resp.marketPrices;
string[] ab1 = prices.Split('|');
string[] temp = ab1[1].Split('~');
textBox3.Text = temp[0];
textBox4.Text = temp[4];
textBox5.Text = temp[8];
temp = ab1[2].Split('~');
textBox6.Text = temp[0];
textBox7.Text = temp[4];
textBox8.Text = temp[8];
temp = ab1[3].Split('~');
textBox9.Text = temp[0];
textBox10.Text = temp[4];
textBox11.Text = temp[8];
temp = ab1[4].Split('~');
textBox12.Text = temp[0];
textBox13.Text = temp[4];
textBox14.Text = temp[8];
if (ab1.Length >5)
{
temp = ab1[5].Split('~');
textBox15.Text = temp[0];
textBox16.Text = temp[4];
textBox17.Text = temp[8];
temp = ab1[6].Split('~');
textBox18.Text = temp[0];
textBox19.Text = temp[4];
textBox20.Text = temp[8];
}
它适用于几个匹配,但我观察到一些其他匹配的字符串变化,因此会产生异常, 任何1可以帮助我一个正确的代码来解压这个字符串,我GOOGLE了它,发现了一个VB代码,这是不是非常有用的,
和BTW,我想安排在一些数据是这样的:
该方法返回一个字符串,价格看起来像一个长谷歌的网址? – Jodrell 2012-07-24 07:17:35
oh gosh,对不起,这是一个错误,我纠正它是真实的:3 – 2012-07-24 07:19:08
(大概)VB.NET代码有什么问题?如果它确实是VB.NET,那么它可以很容易地转换成C#,只需一点技巧。 =)另外,考虑将第二个问题作为第二个问题发布。 =) – 2012-07-24 07:24:06