jack <ga**********@gmail.com> wrote:
I have made it
This is what i found perfectly working
ha ha ..
int year = Convert.ToInt32 ( System.DateTime.Now.Year.ToString ());
int month= Convert.ToInt32 ( System.DateTime.Now.Month.ToString
());
int day = Convert.ToInt32 ( System.DateTime.Now.Day.ToString ());
int hour = Convert.ToInt32 (cmbHour.SelectedItem.Text.ToString ());
int min = Convert.ToInt32 (cmbMin.SelectedItem.Text.ToString ());
DateTime mydate = new DateTime(year,month , day , hour , min ,00);
Why are you converting the year, month and day from an int to a string
and then back again? Similarly, why are you calling ToString() on
SelectedItem.Text (which already returns a string)?
Why not just do:
int hour = int.Parse (cmbHour.SelectedItem.Text);
int min = int.Parse (cmbMin.SelectedItem.Text);
DateTime myDate = new DateTime (DateTime.Now.Year,
DateTime.Now.Month,
DateTime.Now.Day,
hour,
min,
0);
Alternatively:
DateTime myDate = DateTime.Today.AddHours (hour).AddMinutes(minutes);
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too