public Tuple<string , int> TupleTest(string TestStr,int TestInt)
{
string TestStrs = "";
int TestInts=0;
TestStrs = TestStr + "Tuple";
TestInts = TestInt + 10;
return Tuple.Create<string , int>(TestStrs, TestInts);
}
[HttpPost]
public ActionResult Uploads()
{
string ResultStr = "";
int ResultInt = 0;
ExcelToolSetting ex = new ExcelToolSetting();
Tuple<string , int> ConTupleTest = ex.TupleTest("Str", 10);
ResultStr = ConTupleTest.Item1;
ResultInt = ConTupleTest.Item2;
Response.Write("<script language=javascript>alert('"+ ResultStr + "');</" + "script>");
Response.Write("<script language=javascript>alert('"+ ResultInt + "');</" + "script>");
return View("ExcelImport");
}
因為View的部分跟先前介紹過的大同小異,所以前端的部分我這邊就不再多贅述,直接看結果,有興趣的朋友可以看(https://ithelp.ithome.com.tw/articles/10215364) 這邊的分享介紹
最後到網頁中點選按鈕後就可以看到字串後面有加上Tuple和整數有加上10,完成Function一次有多個回傳值的功能