Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# equivalent on java constructor

Tags:

java

c#

android

Not sure if my title is correct. Forgot what it is code. But here I will explain it through code.

You see in Java, you can declare a class like this:

class Panel extends View {

        public Bitmap mBitmap;

        public Panel(Context context) {
            super(context);
        }
}

In C#:

class Panel : View
{
     public Panel(Context context)
     {
         base(context);
     }
}

it throws an error.

How do you declare a class constructor like that in C# ?

like image 277
CodeAndWave Avatar asked Jan 23 '26 05:01

CodeAndWave


1 Answers

class Panel : View
{
    public Panel(Context context) : base(context)
    {
    }
}

MSDN: Using Constructors (C# Programming Guide)

like image 72
zerkms Avatar answered Jan 24 '26 20:01

zerkms



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!