I want to compare two time values in the format of HR:MIN:SEC. of the type string in c#?
<p>Following is a code that a did in comparison between dates. Is it possible to use that code for strings also. OR Is there any sol?</p>

<pre><code>        protected void Button1_Click(object sender, EventArgs e)
        {
            int uid = Convert.ToInt32(dlFaculty.SelectedValue);
            string starttime = Convert.ToString((Convert.ToInt32(dlHour.SelectedItem.Text)) + ":" + (Convert.ToInt32(dlMinute.SelectedItem.Text)) + " " + dlAMPM.SelectedItem.Text);
            string endtime = Convert.ToString((Convert.ToInt32(dlHour1.SelectedItem.Text)) + ":" + (Convert.ToInt32(dlMinute1.SelectedItem.Text)) + " " + dlAMPM1.SelectedItem.Text);
            DateTime startdate = Convert.ToDateTime(txtStartDate.Text);
            DateTime enddate = Convert.ToDateTime(txtEndDate.Text);
            DataTable oTable = new DataTable();
            Boolean flag = true;

            string SQL = "select startdate,enddate from BatchMaster where usermasterid=" + uid + " AND starttime='" + starttime + "' AND endtime='" + endtime + "'";

            oTable = DbHelper.ExecuteTable(DbHelper.CONSTRING, CommandType.Text, SQL, null);
            //coursemasterid = 0;
            //string s = subjectsid;

            if (oTable.Rows.Count &gt; 0)
            {
                DataRow dr = oTable.Rows[0];
                if ((Convert.ToDateTime(dr["startdate"]) &lt;= startdate &amp;&amp; Convert.ToDateTime(dr["enddate"]) &gt;= startdate) || (Convert.ToDateTime(dr["startdate"]) &lt;= enddate &amp;&amp; Convert.ToDateTime(dr["enddate"]) &gt;= enddate))
                {
                    //lblavailability.Visible = true;
                    flag = false;
                    // lblavailability.Text = "Not Available.";
                }

                lblavailability.Visible = true;


                if (flag == true)
                {
                    lblavailability.CssClass = "textgreen";
                    lblavailability.Text = "Available.";
                }
                else
                {
                    lblavailability.CssClass = "errorbold";
                    lblavailability.Text = "Not Available.";
                }
            }
            else
            {
                lblavailability.CssClass = "textgreen";
                lblavailability.Visible = true;
                lblavailability.Text = "Available.";
            }

        }
</code></pre>
