Q:

how to compare 2 lists for equality

even if value in dow and dy are equal,it doesnt enter inside the loop to check equality
foreach (DayOfWeek dow in daysofweek)
{
    foreach (day dy in cleave.WeekDays)
    {
        if (Mode == 1)
        {
            //textBoxnumofdays.Text = Convert.ToString(span.Days+2);
            if (dow.Equals(dy))
            {
                textBoxnumofdays.Text = Convert.ToString(span.Days - 1);
            }
            else
            {
                textBoxnumofdays.Text = Convert.ToString(span.Days + 2);
            }
        }
        else
        {
            //textBoxnumofdays.Text = Convert.ToString(span.Days + 1);
            if (dow.Equals(dy))
            {
                textBoxnumofdays.Text = Convert.ToString(span.Days - 1);
            }
            else
            {
                textBoxnumofdays.Text = Convert.ToString(span.TotalDays + 1);
            }
        }
    }
}

public void Getdays()
{
    DateTime dtFrom = new DateTime(dateTimePickerfromdate.Value.Year,
        dateTimePickerfromdate.Value.Month, dateTimePickerfromdate.Value.Day);
    DateTime dtTo = new DateTime(dateTimePickertodate.Value.Year,
        dateTimePickertodate.Value.Month, dateTimePickertodate.Value.Day);
    daysofweek = new List<DayOfWeek>();           
    cleave = new LeaveApplication(constr);         
    while (dtTo != dtFrom)
    {
        dtFrom = dtFrom.AddDays(1);
        daysofweek.Add(dtFrom.DayOfWeek); 
    }
}

A:

I presume you are trying to check if its a weekday or not
foreach (DayOfWeek dow in daysofweek)
{
}

So just compare it with like dow == DayOfWeek.Sunday and accept or ignore based on your requirement.

