i have a class that i'm trying to understand that overrides
BaseApplication Exception's methods as follows. What i dont' understand is
that i have never seen the inherit ":" on a method signature, only on a
class declaration.
Can you explain what is going on here. Is it that the implementation of the
method that is overriding the base's method simply uses the base's
implementation all along (if so, why override the method to begin with?)?
[Serializable()]
public sealed class BusinessExcepti on : BaseApplication Exception,
ISerializable
{
/// <summary>
/// Initializes a new instance of the <see cref="BusinessE xception"/>
class.
/// </summary>
public BusinessExcepti on() : base()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="BusinessE xception"/>
class with a specified error message.
/// </summary>
/// <param name="message"> The error message that explains the reason for
the exception.</param>
public BusinessExcepti on(string message) : base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="BusinessE xception"/>
class with a specified
/// error message and a reference to the inner exception that is the cause
of this exception.
/// </summary>
/// <param name="message"> The error message that explains the reason for
the exception.</param>
/// <param name="innerExce ption">
/// The exception that is the cause of the current exception. If the
<paramref name="innerExce ption" /> parameter is not a
/// null reference, the current exception is raised in a <c>catch</c>
block that handles the inner exception.
/// </param>
public BusinessExcepti on(string message, Exception innerException) :
base(message, innerException)
{
}
} 4 1456
> public BusinessExcepti on() : base()
That should call the base-class constructor before running your constructor
code.
--
Jonathan Allen
"TS" <ma**********@n ospam.nospam> wrote in message
news:e6******** ******@TK2MSFTN GP14.phx.gbl... i have a class that i'm trying to understand that overrides BaseApplication Exception's methods as follows. What i dont' understand is that i have never seen the inherit ":" on a method signature, only on a class declaration.
Can you explain what is going on here. Is it that the implementation of the method that is overriding the base's method simply uses the base's implementation all along (if so, why override the method to begin with?)?
[Serializable()] public sealed class BusinessExcepti on : BaseApplication Exception, ISerializable { /// <summary> /// Initializes a new instance of the <see cref="BusinessE xception"/> class. /// </summary> public BusinessExcepti on() : base() { }
/// <summary> /// Initializes a new instance of the <see cref="BusinessE xception"/> class with a specified error message. /// </summary> /// <param name="message"> The error message that explains the reason for the exception.</param> public BusinessExcepti on(string message) : base(message) { } /// <summary> /// Initializes a new instance of the <see cref="BusinessE xception"/> class with a specified /// error message and a reference to the inner exception that is the cause of this exception. /// </summary> /// <param name="message"> The error message that explains the reason for the exception.</param> /// <param name="innerExce ption"> /// The exception that is the cause of the current exception. If the <paramref name="innerExce ption" /> parameter is not a /// null reference, the current exception is raised in a <c>catch</c> block that handles the inner exception. /// </param> public BusinessExcepti on(string message, Exception innerException) : base(message, innerException) { } }
You will see this notation only on constructors. There are only two
valid forms:
public MyClass(string myParam1, int myParam2) : base(myParam1)
{ ... }
and
public MyClass(int myParam3) : this(null, myParam3)
{ ... }
In the first case, you are saying, "Before you run my cnstructor code,
run the constructor for my base class and pass it the string myParam1."
In the second case, you are saying "Before you run my constructor code,
run the other constructor for this same class and pass it a null and
the int myParam3."
TS <ma**********@n ospam.nospam> wrote: i have a class that i'm trying to understand that overrides BaseApplication Exception's methods as follows. What i dont' understand is that i have never seen the inherit ":" on a method signature, only on a class declaration.
Can you explain what is going on here. Is it that the implementation of the method that is overriding the base's method simply uses the base's implementation all along (if so, why override the method to begin with?)?
See http://www.pobox.com/~skeet/csharp/constructors.html
Note that no overriding is going on here, as constructors aren't
inherited. Instead, constructors are being provided which call the
appropriate base class constructors.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
thanks all who contributed, i now understand
"TS" <ma**********@n ospam.nospam> wrote in message
news:e6******** ******@TK2MSFTN GP14.phx.gbl... i have a class that i'm trying to understand that overrides BaseApplication Exception's methods as follows. What i dont' understand is that i have never seen the inherit ":" on a method signature, only on a class declaration.
Can you explain what is going on here. Is it that the implementation of
the method that is overriding the base's method simply uses the base's implementation all along (if so, why override the method to begin with?)?
[Serializable()] public sealed class BusinessExcepti on : BaseApplication Exception, ISerializable { /// <summary> /// Initializes a new instance of the <see cref="BusinessE xception"/> class. /// </summary> public BusinessExcepti on() : base() { }
/// <summary> /// Initializes a new instance of the <see cref="BusinessE xception"/> class with a specified error message. /// </summary> /// <param name="message"> The error message that explains the reason for the exception.</param> public BusinessExcepti on(string message) : base(message) { } /// <summary> /// Initializes a new instance of the <see cref="BusinessE xception"/> class with a specified /// error message and a reference to the inner exception that is the
cause of this exception. /// </summary> /// <param name="message"> The error message that explains the reason for the exception.</param> /// <param name="innerExce ption"> /// The exception that is the cause of the current exception. If the <paramref name="innerExce ption" /> parameter is not a /// null reference, the current exception is raised in a <c>catch</c> block that handles the inner exception. /// </param> public BusinessExcepti on(string message, Exception innerException) : base(message, innerException) { } }
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andrew Durdin |
last post by:
In Python, you can override the behaviour of most operators for a
class, by defining __add__, __gt__, and the other special object
methods.
I noticed that, although there are special methods for most operators,
they are conspicuously absent for the logical "or" and "and". I'm
guessing that the reason for this is that these operators
short-circuit if their first operand answers the whole question?
Would it be possible to allow...
|
by: Edward Diener |
last post by:
Is it possible for a derived class to override a property and/or event of
its base class ?
|
by: Hongzheng Wang |
last post by:
Hi,
I have a problem about the overriding of private methods of base
class.
That is, if a method f() of base class is private, can the derived
class overriding f() be overriding?
For example,
class base {
|
by: zero |
last post by:
I'm having trouble with overriding methods in subclasses. I'll explain
the problem using some code:
class BaseClass
{
protected:
void method2();
public:
void method1();
|
by: Robert |
last post by:
Hi,
I've inherited the XmlDocument class to include some custom methods that I
want to use on a particular XML file.
I need to know whether the document has changed since being loaded, and I
wanted to be clever and hook up to the events that are already defined in
the XmlDocument class (i.e. NodeChanged, NodeInserted).
I had presumed I would simply be able to override them, however I cannot
| |
by: ORi |
last post by:
Hi all !
There's a question I've been bothering for a while:
I'm actually developing architectural frameworks for application
developing and I think virtual methods, although needed because of the
flexibility they introduce (flexibility really needed in framework
developing), are often a nuisance for final developers. They don't
like them because they never know if base class must be called and
where should they place the call if...
|
by: ESPNSTI |
last post by:
Hi, I'm very new to C# and .Net, I've been working with it for about a month.
My experience has been mainly with Delphi 5 (not .Net).
What I'm looking for is for a shortcut way to override a property without actually having to reimplement the get and set methods.
In other words, override the the property without changing the functionality of the base property and without explicitly having to reimplement the get and set methods to make it do...
|
by: Bob Weiner |
last post by:
What is the purpose of hiding intead of overriding a method? I have googled
the question but haven't found anything that makes any sense of it.
In the code below, the only difference is that when the Poodle is upcast to
the Dog (in its wildest dreams) it then says "bow wow" where the bernard
always says "woof" (see code). Basically, it appears that I'm hiding the
poodle's speak method from everything except the poodle.
Why would I...
|
by: r035198x |
last post by:
The Object class has five non final methods namely equals, hashCode, toString, clone, and finalize.
These were designed to be overridden according to specific general contracts. Other classes that make use of these methods assume that the methods obey these contracts so it is necessary to ensure that if your classes override these methods, they do so correctly.
In this article I'll take a look at the equals and hashCode methods.
...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |