Hi,
I need to be able to retrieve the Custom Attributes of a class from a method in its base class. Right now I am doing it via a protected static method in the base class with the following implementation (the class can have multiple instances of the same attribute applied):
//Defined in a 'Base' class
protected static CustomAttribute...
I've got a question about ModelBinding in ASP.NET MVC (I'm using MVC 2 preview 2) related to inheritance.
Say I have the following interfaces/classes:
interface IBase
class Base : IBase
interface IChild
class Child: Base, IChild
And I have a custom model binder BaseModelBinder.
The following work fine:
ModelBinders.Binders[typeof(C...
Class names have been changed to protect the innocent.
If I have an interface named ISomeInterface. I also have classes that inherit the interface, FirstClass and SecondClass. FirstClass uses resources that must be disposed. SecondClass does not.
So the question is, where should I inherit from IDisposable? Both of the following opt...
I wanted to make a linked list class ListList that inherits from a class List.
ListList uses functions from List, but has its own functions. It has its own start pointer that points to the beginning of the list, and its own Node struct that holds a different amount of elements.
But, it looks like, when one of List's functions are called...
Hello. It may seems rather newbie question, but can you explain why method Der.B() cannot access protected Foo via Base class variable? This looks weird to me:
public class Base
{
protected int Foo;
}
public class Der : Base
{
private void B(Base b) { Foo = b.Foo; } // Error: Cannot access protected member
private void D(D...
Without any code in the subclasses, I'd like an abstract class to have a different copy of a static variable for each subclass. In C#
abstract class ClassA
{
static string theValue;
// just to demonstrate
public string GetValue()
{
return theValue;
}
...
}
class ClassB : ClassA { }
class ClassC : ClassA ...
I have two closely related classes which I'll call Widget and Sprocket. Sprocket has a set of methods which I want to be callable from Widget but not from any other class. I also don't want to just declare Widget a friend of Spocket because that would give Widget access to ALL protected and private members. I want to restrict Widget's ac...
Say I have the following hierarchy:
public class MyClass
{
protected virtual void Method() { ... }
}
public class MySubClass : MyClass
{
public new virtual void Method() { ... }
}
public class MySubSubClass : MySubClass
{
// how do I reference the protected Method() to override it?
}
Is it possible to override the implementati...
I just read this nice article that taught me how to use inheritance (Table-per-hirarchy).
I was wondering, say I have a column 'HireDate' that need to use in the sub-class.
That's for sure that in the DB it has to marked as nullable, but how can I mark it not nullable in the EDM?
I tried to set it as not-nullable, but then it says that ...
I have this simple structure: 1 parent, and two different childs.
public class Parent{}
public class ChildA : Parent{}
public class ChildB : Parent{}
I have an object objA of type ChildA, which I want to cast to ChildB. My naive approach says:
ChildA objA = new ChildA();
ChildB objB = (ChildB)objA;
But this is not directly possi...
I am experiencing some annoying behavior with Visual Studio .NET 2008.
We have created a base form, and a base grid derived from Infragistics UltraGrid.
In the base form, we have set some properties like colors, font size, etc.
1. We create a new Windows Form, (i.e. DerivedForm)
2. We change the inheritance to BaseForm, by simply addin...
I am trying to do something like this in C#
public class ParentClass {
public static ParentClass GetSomething()
{
var thing = new // ?????
return thing;
}
}
public class ChildClass : ParentClass {
}
And then I want to be able to call the static method on the child class like so:
ChildClass blah = ChildClass.GetSomethin...
Hello folks!
I am trying to set an inheritance in Entity-Framework, I want to set the mapping when BooleanColumn = True.
I am unable to do so.
...
So I am trying to make a parameterized type that will work for anytype in Java this includes anything that is an object, and also the primitives types. How would i go about doing this?
Ok, suppose I want the target of a for-each to be a primitive, so its
for(int i : MyClass)
something like that. Is this possible to do?
...
Output:
B->Hello! from Explicit.
Shouldn't it be:?
A->Hello! from Explicit.
Why doesn't explicit cast (IHello)a call IHello.Hello() from class A?
interface IHello
{
void Hello();
}
class A : IHello
{
public virtual void Hello()
{
Console.WriteLine("A->Hello!");
}
void IHello.Hello()
{
Co...
package package.b;
class ClassB {
public ClassB(BaseClass bc, XMLBase obj1) { }
}
import package.b.ClassB;
class A extends BaseClass {
public void function() {
TestXML obj1 = new TestXML();
ClassB bObj = new ClassB(this, obj1);
}
}
When I compile the above code, I get an error "cannot find symbol symb...
We have a parent model Vehicle that is inherited to make classes Car, Truck, SUV. In our form, we allow the user to edit the data for a bunch of Vehicles, and one of the attributes for each vehicle is a select menu for "type". The HTML attribute is named vehicle_type and updates the actual Polymorphic type attribute in the Vehicle Model:...
Basically, what I want is to do this:
class B:
def fn(self):
print 'B'
class A:
def fn(self):
print 'A'
@extendInherit
class C(A,B):
pass
c=C()
c.fn()
And have the output be
A
B
How would I implement the extendInherit decorator?
...
I am just starting to get to grips with generics and am (ab)using them to refactor a fairly complex section of my code (I've only been using c# for a little while but am fairly experienced in other languages).
I have an inheritance structure where my classes extend a base class. In the base class I have most of the functionality impleme...
First let's establish this.
I have
public abstract class Foo
{
public static void StaticMethod()
{
}
}
public class Bar : Foo
{
}
is it valid to call
Bar.StaticMethod();
???
If so, let's expand previous example:
public abstract class Foo
{
public static void StaticMethod()
{
}
public abstract void VirtualMethod();
...