此代码用于使用Xe.com的货币转换器 [英] This code is use for Currency Convertor using Xe.com

查看:113
本文介绍了此代码用于使用Xe.com的货币转换器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public void currency(string srcCurrency,string dstCurrency)

{

string xeString = String.Format(http://www.xe.com/ucc/ convert.cgi?Amount = 1&From = {0}&To = {1},srcCurrency,dstCurrency);

System.Net.WebRequest wreq = System.Net.WebRequest.Create(new Uri(xeString) ));

System.Net.WebResponse wresp = wreq.GetResponse();

Stream respstr = wresp.GetResponseStream();

int read = respstr.Read(buf,0,BUFFER_SIZE);

string result = Encoding.ASCII.GetString(buf,0,read);

}







错误:错误16当前上下文中不存在名称'BUFFER_SIZE'

public void currency(string srcCurrency,string dstCurrency)
{
string xeString = String.Format("http://www.xe.com/ucc/convert.cgi?Amount=1&From={0}&To={1}", srcCurrency, dstCurrency);
System.Net.WebRequest wreq = System.Net.WebRequest.Create(new Uri(xeString));
System.Net.WebResponse wresp = wreq.GetResponse();
Stream respstr = wresp.GetResponseStream();
int read = respstr.Read(buf, 0, BUFFER_SIZE);
string result = Encoding.ASCII.GetString(buf, 0, read);
}



error:Error 16 The name 'BUFFER_SIZE' does not exist in the current context

推荐答案

您没有声明变量 BUFFER_SIZE 。可能你已经在课程顶部创建了变量&将更多代码移到某个地方。检查 Stream.Read方法 [ ^ ]
You didn't declare the variable BUFFER_SIZE. Possibly you had created the variable at top of the class & moved that with some more code to somewhere. Check Stream.Read Method[^]


这篇关于此代码用于使用Xe.com的货币转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆