需要一些将Java代码Android Studio移植到C#Visual Studio的帮助吗
我需要一些帮助来将一段Java代码移植到C#。代码是关于对web api的post请求,以建立我在Java中使用的Volley连接,并且我已经在Visual Studio中安装了NuGet。我无法将StringRequest函数转换为C#
这是我目前试图在C#中移植的一段代码,但在C#中声明参数时出错。例如,它无法识别请求。方法和新的响应。听众
StringRequest stringRequest = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>()
{
@Override
public void onResponse(String response)
{
Log.i("Volley Response", response);
}
}, new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error)
{
Log.e("Volley Error", error.toString());
}
})
{
@Override
public String getBodyContentType()
{
return "application/json; charset=utf-8";
}
@Override
public byte[] getBody()
{
try
{
return requestBody.getBytes("utf-8");
}
catch (UnsupportedEncodingException uee)
{
return null;
}
}
};
requestQueue.add(stringRequest);
return stringRequest;
如果有人能这么好地帮我把它移植到C#,我会非常高兴
# 1 楼答案
我自己解决了这个问题,没有使用截击,也没有移植java代码
再次抱歉要求移植,我不知道这不是我应该在这里要求的。感谢jrswgtr让我知道
这是一段代码,用于向web api发出简单的POST请求,从两个editbox获取值,并在单击按钮后发送它们
使用定义的模型更新代码