This is most frequent question of interviewer ‘tell me the real scenario where you have used interface’. I would like to explain my experience where I have used Interface.
I have created a class named ‘CCommon’. In which I have defined a method named Load(..). The functionality of Load was to set the forms properties like. WindowState,MaximizeBox, BackColor etc. It is required to set these properties for each form. I need to call this method for each ‘n’ every form in the project.
So I have required such object in Load function which can be used for every form. In this order I have created an Interface ICommon and implement every form from this Interface.
And defined Load method as
///
///
///
///
internal void Load(ICommon objICommon)
{
objICommon.Text_Form = ApplicationName;
objICommon.MaximizeBox_Form = false;
// objICommon.MinimizeBox_Form = false;
objICommon.MinimumSize_Form = new Size(objICommon.Width_Form, objICommon.Height_Form);
objICommon.MaximumSize_Form = new Size(objICommon.Width_Form, objICommon.Height_Form);
objICommon.StartPos_Form = FormStartPosition.CenterScreen;
}
No comments:
Post a Comment