tagged [inheritance]

Inheritable only inside assembly in C#

Inheritable only inside assembly in C# In C# Is there way to specify a class to be inherited only by a class present in the same assembly and for other assemblies should behave like a public sealed ty...

10 Mar at 13:56

C# Interfaces- only implement an interface in other interfaces

C# Interfaces- only implement an interface in other interfaces I would like to only implement certain interfaces within other interfaces, I don't want them to be able to be inherited directly by a cla...

17 Feb at 18:44

C# : Transitive Inheritance

C# : Transitive Inheritance Is Inheritance a transitive relation in C#? I am asking because I cannot understand why `IList` implements `ICollection` and `IEnumerable` as `ICollection` already implemen...

30 Jan at 23:12

Inherit from a class or an abstract class

Inherit from a class or an abstract class If you have several classes where you want them to inherit from a base class for common functionality, should you implement the base class using a class or an...

2 Mar at 19:35

Preventing override of individual methods in C#

Preventing override of individual methods in C# I know that I can use the sealed in order to prevent other classes to inherit a certain class, but is it possible to allow inheritance but prevent overr...

11 Mar at 15:48

C# constructor execution order

C# constructor execution order In C#, when you do is the constructor of the class executed first, and then the superclass constructor is called or does it call the base constructor first?

When to use an interface instead of an abstract class and vice versa?

When to use an interface instead of an abstract class and vice versa? This may be a generic OOP question. I wanted to do a generic comparison between an interface and an abstract class on the basis of...

Why should constructors on abstract classes be protected, not public?

Why should constructors on abstract classes be protected, not public? ReSharper suggests changing the accessibility of a `public` constructor in an `abstract` class to `protected`, but it does not sta...

C# Reflection - Base class static fields in Derived type

C# Reflection - Base class static fields in Derived type In C#, when I'm reflecting over a derived type, how come I don't see base classes' static fields? I've tried both `type.GetFields(BindingFlags....

13 Feb at 14:52

How to call protected constructor in c#?

How to call protected constructor in c#? How to call protected constructor? This obviously fails test:

15 Aug at 05:43

Should C# have multiple inheritance?

Should C# have multiple inheritance? I have come across numerous arguments against the inclusion of multiple inheritance in C#, some of which include (philosophical arguments aside): - - - I come from...

11 Nov at 20:58

Inheriting constructors

Inheriting constructors Why does this code: Result in these errors: Shouldn't B inherit A's constructor? (this is using gcc)

7 Mar at 06:39

C# interface static method call with generics

C# interface static method call with generics Is there a simple way to implement this, and if possible without instanciating an object :

How to implement Active Record inheritance in Ruby on Rails?

How to implement Active Record inheritance in Ruby on Rails? How to implement inheritance with active records? For example, I want a class Animal, class Dog, and class Cat. How would the model and the...

Class extending more than one class Java?

Class extending more than one class Java? I know that a class can implement more than one interface, but is it possible to extend more than one class? For example I want my class to extend both `Trans...

Does C# support multiple inheritance?

Does C# support multiple inheritance? A colleague and I are having a bit of an argument over multiple inheritance. I'm saying it's not supported and he's saying it is. So, I thought that I'd ask the b...

16 Mar at 16:28

Interface inheritance: is extending properties possible?

Interface inheritance: is extending properties possible? I want to do this: So that `IInherited` would have the property `Property1` with added functionality to allow `set`. Is that possible? What's t...

18 Aug at 21:19

base() and this() constructors best practices

base() and this() constructors best practices Under what conditions am I supposed to make the `:base()` and `:this()` constructor calls following my constructor's parentheses (or even in other places ...

Virtual methods without body

Virtual methods without body I was looking at some code in an abstract class: Why should I declare an empty virtual method in an abstract class if it is not mandatory to override it in derived types?

20 Oct at 14:6

What does it mean that Javascript is a prototype based language?

What does it mean that Javascript is a prototype based language? One of the major advantages with Javascript is said to be that it is a prototype based language. But what does it mean that Javascript ...

How to disable parameterless constructor in C#

How to disable parameterless constructor in C# For the class CBase, it should be initialized by providing the parameter, so how to disable the parameterless constructor for CBase class?

How can I get all the inherited classes of a base class?

How can I get all the inherited classes of a base class? How would I be able to get all the classes that use Foo as a base class? The inherited classes aren't necessary in the same assembly.

3 Nov at 03:50

C# - How can i wrap a static class

C# - How can i wrap a static class I want to make util classes for System.Io (such as File, Directory etc). Since inheritance cannot be done for static classes i want to know how would be a proper way...

24 Dec at 10:52

Allowing implementing interface only for specific classes

Allowing implementing interface only for specific classes Is it possible to permit only some specific classes to implement an iterface? Let's say that I created interface `IMyInterface` and I want onl...

24 Apr at 16:48

What is the difference between a class having private constructor and a sealed class having private constructor?

What is the difference between a class having private constructor and a sealed class having private constructor? Is there any difference between A and B? Class A has private constructor: Class B is se...

20 May at 06:32