'C# Contained Class Inherit From Base Class [closed]
I have the following structure
public class mymainClass
{
public class containedClass : would like to Inherit Class here (without doing it here)
{properties {get;set;}
}
public class mymainClass
{
public class containedClass : InheritClass BUT DONT SPECIFY INTERNALLY
{properties {get;set;}
}
I would love to do this - but WE KNOW IT CANT BE DONE.
public class mymainClass<T>
{
public class containedClass : T
{properties {get;set;}
}
How can I accomplish getting the contained class to inherit form something I specify in the container class construction ?
EDIT Right now I need to create these classes specifically for the fact that the internal class is specific, if I can write the whole thing generically I can pass in the specific item and simplify ..
So the internal Class ..
Perhaps I could do something like
public class mymainClass<T>
{
public mymainClass<T>(){
this.containedClass = T;
}
public class containedClass : would like to Inherit Class here (without doing it here)
{properties {get;set;}
}
Solution 1:[1]
Are you trying to do this?
public class Main<T>
where T: Main<T>.Nested
{
public class Nested { }
}
public class Derived:Main<Derived.DerivedNested> {
public class DerivedNested : Nested{ }
}
Or perhaps something like;
public class Main<T>
where T: Main<T>.INested
{
public interface INested {
void DefaultMethod() { ... }
}
}
(this probably doesn't count as an "Answer", but is too complex for a comment...)
Solution 2:[2]
i have same problem:
you could try some encodings if Default not functional:
"Windows 1252" -> Encoding.GetEncoding(1252); #Europe Ouest (Windows)
"ISO-8859-1" -> Encoding.GetEncoding(28591); #Europe occidentale (ISO)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 |
