473,499 Members | 1,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

overriding inheritted methods syntax

TS
i have a class that i'm trying to understand that overrides
BaseApplicationException'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 BusinessException : BaseApplicationException,
ISerializable
{
/// <summary>
/// Initializes a new instance of the <see cref="BusinessException"/>
class.
/// </summary>
public BusinessException() : base()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="BusinessException"/>
class with a specified error message.
/// </summary>
/// <param name="message">The error message that explains the reason for
the exception.</param>
public BusinessException(string message) : base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="BusinessException"/>
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="innerException">
/// The exception that is the cause of the current exception. If the
<paramref name="innerException" /> parameter is not a
/// null reference, the current exception is raised in a <c>catch</c>
block that handles the inner exception.
/// </param>
public BusinessException(string message, Exception innerException) :
base(message, innerException)
{
}
}
Nov 17 '05 #1
4 1448
> public BusinessException() : base()

That should call the base-class constructor before running your constructor
code.

--
Jonathan Allen
"TS" <ma**********@nospam.nospam> wrote in message
news:e6**************@TK2MSFTNGP14.phx.gbl...
i have a class that i'm trying to understand that overrides
BaseApplicationException'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 BusinessException : BaseApplicationException,
ISerializable
{
/// <summary>
/// Initializes a new instance of the <see cref="BusinessException"/>
class.
/// </summary>
public BusinessException() : base()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="BusinessException"/>
class with a specified error message.
/// </summary>
/// <param name="message">The error message that explains the reason for
the exception.</param>
public BusinessException(string message) : base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="BusinessException"/>
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="innerException">
/// The exception that is the cause of the current exception. If the
<paramref name="innerException" /> parameter is not a
/// null reference, the current exception is raised in a <c>catch</c>
block that handles the inner exception.
/// </param>
public BusinessException(string message, Exception innerException) :
base(message, innerException)
{
}
}

Nov 17 '05 #2
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."

Nov 17 '05 #3
TS <ma**********@nospam.nospam> wrote:
i have a class that i'm trying to understand that overrides
BaseApplicationException'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.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4
TS
thanks all who contributed, i now understand
"TS" <ma**********@nospam.nospam> wrote in message
news:e6**************@TK2MSFTNGP14.phx.gbl...
i have a class that i'm trying to understand that overrides
BaseApplicationException'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 BusinessException : BaseApplicationException,
ISerializable
{
/// <summary>
/// Initializes a new instance of the <see cref="BusinessException"/>
class.
/// </summary>
public BusinessException() : base()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="BusinessException"/>
class with a specified error message.
/// </summary>
/// <param name="message">The error message that explains the reason for
the exception.</param>
public BusinessException(string message) : base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="BusinessException"/>
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="innerException">
/// The exception that is the cause of the current exception. If the
<paramref name="innerException" /> parameter is not a
/// null reference, the current exception is raised in a <c>catch</c>
block that handles the inner exception.
/// </param>
public BusinessException(string message, Exception innerException) :
base(message, innerException)
{
}
}

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3772
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...
8
2236
by: Edward Diener | last post by:
Is it possible for a derived class to override a property and/or event of its base class ?
5
2704
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...
5
2764
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();
1
1630
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...
4
1914
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...
2
3585
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...
17
2895
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...
10
104959
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...
0
7009
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7178
Oralloy
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,...
0
7390
tracyyun
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...
0
5475
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4602
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...
0
3103
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...
0
3094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
302
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.