I am beginner in software field. And I have problem in passing Datetime to a class constructor. So there is one ASP.Net MVC 5 application and it interacts with VB.net code for backend work. (Humor me on this).
Here is what I have till now.
ViewModel:
public class Add
{
public DateTime? dateTime { get; set; }
}
Controller:
[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 constructor definition:
public ClsArgs(DateTime ExpirationDate);
Below solution works:
[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);in your first controller block