我有两种方法
public void GetEmp()
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new System.Uri("http://sdw2629/empservice/EmployeeInfo.svc/Employee"));
request.Method = "GET";
request.ContentType = "application/json; charset=utf-8";
request.BeginGetResponse(new AsyncCallback(ReadWebRequestCallback), request);
}
Run Code Online (Sandbox Code Playgroud)
和
private void ReadWebRequestCallback(IAsyncResult callbackResult)
{
HttpWebRequest myRequest = (HttpWebRequest)callbackResult.AsyncState;
using (HttpWebResponse myResponse = (HttpWebResponse)myRequest.EndGetResponse(callbackResult))
{
using (StreamReader httpwebStreamReader = new StreamReader(myResponse.GetResponseStream()))
{
string results = httpwebStreamReader.ReadToEnd();
//execute UI stuff on UI thread.
}
}
}
Run Code Online (Sandbox Code Playgroud)
在这里,我想返回一个字符串"results"到这样的其他方法
string data= obj1.GetEmp()
Run Code Online (Sandbox Code Playgroud)
我怎样才能实现这一目标..任何帮助都会得到满足......谢谢
我有一个数组元素
[{
"x": 326,
"y": 176
}, {
"x": 244,
"y": 300
}, {
"x": 189,
"y": 420
}, {
"x": 154,
"y": 546
}, {
"x": 139,
"y": 679
}, {
"x": 152,
"y": 827
}, {
"x": 183,
"y": 954
}, {
"x": 230,
"y": 1088
}, {
"x": 291,
"y": 1217
}, {
"x": 365,
"y": 1333
}, {
"x": 446,
"y": 1417
}, {
"x": 554,
"y": 1469
}]
Run Code Online (Sandbox Code Playgroud)
我想将此转换为字符串
"{326,176},{244,300},{189,420},{154,546},{139,679},{152,827},{183,954}, {230,1088},{291,1217},{365,1333},{446,1417},{554,1469}"
Run Code Online (Sandbox Code Playgroud)
我们怎样才能在javascript中实现这一点..在此先感谢..
我试图对包含具有“在线”、“离线”、“忙碌”状态键的对象数组进行排序,因此只想以所有“在线”都出现在顶部的方式对数组进行排序,然后是“忙碌” ”然后“离线”
var arr = [{_id: "58e21249", name: "test2", status: "offline"},
{_id: "58e1249", name: "test3", status: "online"},
{_id: "58qwe49", name: "test21", status: "offline"},
{_id: "58ed49", name: "test212", status: "online"},
{_id: "58ee49", name: "test23", status: "offline"},
{_id: "58xe49", name: "test12", status: "online"},
{_id: "5849", name: "test2323", status: "busy"},
{_id: "58er49", name: "test2121", status: "busy"}];
arr.sort(function(first, second) {
if (second.status == "online") return 1;
});
console.log(arr);
Run Code Online (Sandbox Code Playgroud)
这只会返回我的状态:顶部的“在线”。谢谢
我有两个decimal值
3.10m = 3 years 10 months
2.8m = 2 years 8 months.
Run Code Online (Sandbox Code Playgroud)
我正在尝试sum这些值,结果5.9是不正确的.
该预期的结果应该是
6.6m = 6 years 6 months
Run Code Online (Sandbox Code Playgroud)
任何人都可以建议我们如何TimeSpan在C#中使用或以任何其他方式实现此目的.提前致谢
arrays ×2
c# ×2
javascript ×2
asynchronous ×1
datetime ×1
sorting ×1
string ×1
timestamp ×1
void ×1