Its better to accept my mistake with this question. I messed up things thats why i had this problem. Sorry for bothering you people ...
string name = ((DateTimePicker)sender).Name.ToString();
name = name.Substring(0, name.Length - 1);
name = name + "4";
TimeSpan duration = new TimeSpan();
duration = ((DateTimePicker)sender).Value - ((DateTimePicker)panel2.Controls[name]).Value;
name = name.Substring(0, name.Length - 1);
name = name + "6";
((MaskedTextBox)panel2.Controls[name]).Text = duration.ToString();
On execution it gives me Object reference not set to instance of an object similar functionality is used on other places but I can't find out what I have to reinitialize here :$
The casting for datetimepicker is fine I have to get a name for the datetiempicker to identify the row it's on in my form and the picker before that to calculate their differences and then print that difference in a maskedtext box from the control whose name I make using names of two datetimepickers but when I access controls in the error line I get this message.