locked
MVC method that returns three dateTime values RRS feed

  • Question

  • User-507786106 posted
    I need help constructing a method that returns three date values.
    Thank you
    Wednesday, May 29, 2019 9:15 PM

Answers

  • User1520731567 posted

    Hi slimbunny,

    I need help constructing a method that returns three date values.

    For example:

            public IEnumerable<DateTime> MyMethod()
            {
               ...
                var list = db.Tables.Select(_ => _.DateTimeFieldName).Take(3);
                return list;
            }

    And then call this method.

    Best Regards.

    Yuki Tao

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 30, 2019 7:34 AM

All replies

  • User475983607 posted

    I need help constructing a method that returns three date values.

    Create a class with 3 date properties.    Populate the object properties and return the object.

        public class MyDates {
            public DateTime Date1 { get; set; }
            public DateTime Date2 { get; set; }
            public DateTime Date3 { get; set; }
        }
    public MyDates MyMethod() 
    {
      //Do something
    }

    Or return an array of dates.

    public DateTime[] MyMethod() 
    {
      //Do something
    }



    Wednesday, May 29, 2019 9:22 PM
  • User1520731567 posted

    Hi slimbunny,

    I need help constructing a method that returns three date values.

    For example:

            public IEnumerable<DateTime> MyMethod()
            {
               ...
                var list = db.Tables.Select(_ => _.DateTimeFieldName).Take(3);
                return list;
            }

    And then call this method.

    Best Regards.

    Yuki Tao

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 30, 2019 7:34 AM