Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does base.OnStartup(e) do?

Tags:

c#

wpf

app.xaml

I see that many people use "base.OnStartup(e)" inside of App.xaml.cs like this:

protected override void OnStartup(StartupEventArgs e)
{
    base.OnStartup(e);

    MainWindow app = new MainWindow();
    app.Show();
}

Is there a need for it? What is the purpose for it?

like image 600
JP Garza Avatar asked May 04 '26 03:05

JP Garza


1 Answers

It allows any base class logic to run; just like any other usage of base.

Its probably not strictly necessary; but calling a base class's implementation when overriding virtual methods is considered a best practice (unless you actively want to suppress the base behavior).

like image 89
BradleyDotNET Avatar answered May 06 '26 17:05

BradleyDotNET



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!