Link to home
Start Free TrialLog in
Avatar of wademi
wademi

asked on

C# method that returns date

I need help creating a method in C# that returns the "start date of last month" and the "Current date" .  I am not sure of the best way to return the dates .

I would like to be able to use the return value in another method and refer to the dates like:

Returnval.MonthStartdate
Returnval.Currentdate

Maybe the method should return the dates as an Enum

The dates should be in the format like 11/15/2011 and be a string.
Avatar of kaufmed
kaufmed
Flag of United States of America image

Create a new struct/class that has your members:

struct DateInfo
{
    public string MonthStartdate { get; set; }
    public string Currentdate { get; set; }
}

Open in new window


Then use that new definition as your return type:

public DateInfo SomeFunction() ...

Open in new window


Then it becomes a matter of simply creating a new instance of the data structure, populating it, and returning it.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No assist for kaufmed?...   =\