Can anyone telme whats wrong in this part of code

Posted by Mobin on Stack Overflow See other posts from Stack Overflow or by Mobin
Published on 2010-05-14T13:42:37Z Indexed on 2010/05/14 13:44 UTC
Read the original article Hit count: 276

Filed under:
|
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 can't find out what i have to reinitialize here :$

© Stack Overflow or respective owner

Related posts about c#

Related posts about maskedtextbox