Calling the base constructor in C#

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Calling the base constructor in C#

Message par ForumBot »

Calling the base constructor in C#
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Calling the base constructor in C#

Message par ForumBot »

Modify your constructor to the following so that it calls the base class constructor properly:

```
public class MyExceptionClass : Exception
{
public MyExceptionClass(string message, string extrainfo) : base(message)
{
//other stuff here
}
}

```

Note that a constructor is not something that you can call anytime within a method. That's the reason you're getting errors in your call in the constructor body.
Répondre

Revenir à « .NET & C# »