我是軟件領域的初學者。我在將Datetime傳遞給類構造函數時遇到了問題。所以有一個ASP.Net MVC 5應用程序,它與後端工作的VB.net代碼交互。 (在這個幽默我)。無法在ASP.Net MVC 5中傳遞日期時間
這是我到現在爲止。
視圖模型:
public class Add
{
public DateTime? dateTime { get; set; }
}
控制器:
[HttpPost]
public ActionResult AddLocationBlock(Add viewModel)
{
if(viewModel.dateTime !=null)
{
ClsArgs obj1 = new ClsArgs((viewModel.dateTime);
^^ ERROR: matching constructor not found
}
return new EmptyResult();
}
VB.net構造定義:
public ClsArgs(DateTime ExpirationDate);
貝爾流解決方案的工作:
[HttpPost]
public ActionResult AddLocationBlock(Add viewModel)
{
if(viewModel.dateTime !=null)
{
DateTime dte = new DateTime();
ClsArgs obj1 = new ClsArgs(dte);
}
return new EmptyResult();
}
只是注意,你有這樣的:'ClsArgs((viewModel.dateTime);'你的第一個控制器塊 –