In my early day career in many interviews I asked same question, what is overloading and overriding so decided to write this small article which may help someone. We will see here in detail about the overloading, overriding and then differences between them.
Overloading: is the mechanism to have more than one method with same name but with different signature (parameters). A method can be overloaded on the basis of following properties
- Have different number of parameter
- Having same number of parameters but of different type
- Having same number and type of parameters but in different orders
In the <triggers> template in an update panel, there are the options of an AsyncPostBackTrigger or a PostBackTrigger. By default, controls outside of an update panel will trigger a normal synchronous post back. The AsyncPostBackTrigger “wires” up these controls to trigger an asynchronous post back. Conversely, controls declared inside an update panel will trigger an asynchronous call by default. The PostBackTrigger short circuits this, and forces the control to do a synchronous post back. Utilizing a simple “time” example:
StatusBar Example
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace StatusBarExample
{
/// <summary>
/// Summary description for StatusBarExample.
/// </summary>
public class StatusBarExample : System.Windows.Forms.Form
{
internal System.Windows.Forms.StatusBar statusBar;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public StatusBarExample()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.statusBar = new System.Windows.Forms.StatusBar();
this.SuspendLayout();
//
// statusBar
//
this.statusBar.Location = new System.Drawing.Point(0, 138);
this.statusBar.Name = "statusBar";
this.statusBar.ShowPanels = true;
this.statusBar.Size = new System.Drawing.Size(292, 24);
this.statusBar.SizingGrip = false;
this.statusBar.TabIndex = 1;
//
// StatusBarExample
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
this.ClientSize = new System.Drawing.Size(292, 162);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.statusBar});
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.Name = "StatusBarExample";
this.Text = "StatusBar Example";
this.Load += new System.EventHandler(this.StatusBarExample_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new StatusBarExample());
}
private void StatusBarExample_Load(object sender, System.EventArgs e)
{
StatusBarPanel pnlStatus = new StatusBarPanel();
pnlStatus.Text = "Ready";
pnlStatus.Icon = new Icon(Application.StartupPath + "\\active.ico");
pnlStatus.AutoSize = StatusBarPanelAutoSize.Contents;
StatusBarPanel pnlConnection = new StatusBarPanel();
pnlConnection.Text = "Connected to " + "localhost";
pnlConnection.AutoSize = StatusBarPanelAutoSize.Spring;
statusBar.Panels.Add(pnlStatus);
statusBar.Panels.Add(pnlConnection);
}
}
}
