I'm creating a class to manage exception in c#, and I'd like to create some constructor methods which recalls the superclass; this is the definition of my class:
class DataSourceNotFoundException: System.Exception
but since in c# there is no super method what am I supposed to call to get the constructor methods of System.Exception
?
Definition. A super loop is a program structure comprised of an infinite loop, with all the tasks of the system contained in that loop.
Because there are no operating system to return to or an embedded device is running until the power supply is removed. So, to run set of statements, we need a loop that must not be finished, such kind of loops are known as 'Super Loop' or 'Infinite Loop'.
The watchdog timer is used for monitoring the firmware execution which is a hardware timer.
You call a parent constructor using base
before the body of the constructor:
public class FooException : Exception
{
public FooException(string message) : base(message)
{
}
}
Obviously you don't have to just pass a parameter from your own constructor up as an argument to the base constructor:
public class FooException : Exception
{
public FooException(int x) : base("Hello")
{
// Do something with x
}
}
The equivalent to chain to a constructor in the current class is to use this
instead of base
.
Note that constructor chaining works very slightly differently in C# compared with Java, with respect to when instance variable initializers are run. See my article on C# constructors for more details.
In general the keyword base
is what you want. Check http://msdn.microsoft.com/en-us/library/hfw7t1ce(v=vs.71).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With