inheritance

Inherited class giving null exceptions.

Here is my simple class, where i inherit from UserControl. public class Test:System.Web.UI.UserControl { public void BindGrid() { Response.Write(IsPostBack); } } Which i call from the Page_Load event protected void Page_Load(object sender, EventArgs e) { new Test().BindGrid(); } But i get a null reference exc...

C# add custom attributes for a parent's property in an inherited class

Hi, I'm displaying Business Object in generic DataGrids, and I want to set the column header through a custom attribute, like: class TestBo { [Header("NoDisp")] public int ID {get; set;} [Header("Object's name")] public String Name { get; set; } } So far, so good, but I'd also want to separate my display from my dat...

Is it possible to simultaneously and generically subclass both a bounded generic class and a generic interface?

I'm trying to create a new class by subclassing another generic class (with a bound) and implementing a generic interface (without a bound): public class Foo1<T extends Bar> { ... } public interface Foo2<T> { ... } public class ProblemClass<T extends Bar, U> extends Foo1<T extends Bar> implements Foo2<U> { ... } ...

What's the difference between using the Serializable attribute & implementing ISerializable?

Hi folks, what's the difference between using the Serializable attribute and implementing the ISerializable interface? Please clarify. TIA ...

Can't access instance of custom inherited webcontrol from code-behind page in Web Application project

I've inherited from an ASP.NET WebControl to add some additional functionality. I tested my control in a blank ASP.NET Web Site (created through File > New Web Site...) and it worked fine. But I can't get it to work when I add it to a Web Application Project (created throgh File > New Project... > Visual Basic > Web > ASP.NET Web Appli...

C++ private virtual inheritance problem

In the following code, it seems class C does not have access to A's constructor, which is required because of the virtual inheritance. Yet, the code still compiles and runs. Why does it work? class A {}; class B: private virtual A {}; class C: public B {}; int main() { C c; return 0; } Moreover, if I remove the default constr...

Inheritance from multiple interface with the same method name in C#

If we have a class that inherits from multiple interfaces, and the interfaces have methods with the same name, how can we implement these methods in my class? How we can specify that which method of which interface is implemented? ...

Overriding and overridden methods must have same accessibility, so why isn’t same true for Page.CreateChildControls()?

Methods marked as virtual can be overridden in derived classes. One of the restrictions is that overriding and overridden methods must have same accessibility. Thus, if virtual method is marked as protected internal, then overriding method must also be marked as protected internal (it cannot be for example marked as just protected). Si...

Since Control.CreateChildControls is marked as protected internal, it should not be visible inside...

I can’t figure out why Control.CreateChildControls is visible in web page’s code-behind class. Namely, Control.CreateChildControls is defined as protected internal, which means that method is visible only to derived classes located inside the same assembly as Control class. So how is that possible since as as far as I know, web-page clas...

How To Get Classes To Expose The Same Shared/Static Method

I have a base class with several derived classes. I want all of my derived classes to have the same Public Shared (static) method with their own implementation. How do I do this? Is it even possible? ...

Prevent Massive Shadowing Of Methods

I'm in a project where it's pretty much my first time doing all the architecture myself, and I'm running into a frustrating situation. My architecture for forms seems to be correct from a heuristic perspective, but I don't think its implementation is correct. My architecture is thus: Base Class: OrderForm Child Classes: PurchaseOrder...

Inheritance classes in Scheme

Now I research OOP-part of Scheme. I can define class in Scheme like this: (define (create-queue) (let ((mpty #t) (the-list '())) (define (enque value) (set! the-list (append the-list (list value))) (set! mpty #f) the-list) (define (deque) (set! the-list (cdr the-list)) (if (= (length t...

What does this Java generics paradigm do and what is it called?

I'm looking at some Java classes that have the following form: public abstract class A <E extends A<E>> implements Comparable <E> { public final int compareTo( E other ) { // etc } } public class B extends A <B> { // etc } public class C extends A <C> { // etc } My usage of "Comparable" here is just to ...

Confusing Java generics usage: how do I properly parameterize this?

I'm looking at some code with this form: 1 package com.stackoverflow.java.questions; 2 import java.util.ArrayList; 3 import java.util.List; 4 public class B extends A<B> { 5 6 private 7 <C extends A> 8 List<C> getList(Class<C> cls) { 9 10 Li...

Objective-C: changing object inside NSMutableArray

In my program I have two classes: Collector and Entity. Collector stores Entities in NSMutableArray. @interface Entity : NSObject { ... } @interface Collector : NSObject { NSMutableArray *entities; uint someInt; ... } - (void)addEntity:(Entity*)newEntity; // implemented as [entities addObject:newEntity]; Collectors ...

Best approach for a multi-tab ASP.NET AJAX control?

Looking for some implementation advice: I have a page that has a 3-tab ajaxToolkit:TabContainer. The purpose of the page is to expose a calculator that has two basic inputs: geo-location and date. The three tabs are labeled "City and State", "Postal Code", and "GPS Coordinates". The layout of each tab container is the same for each tab,...

Extending the base class

When you create a webpage in ASP.net, the codebase inherits System.Web.UI.Page Now when I extend the page object to check for SessionExpired for example, I create a new class and inherit from system.web.ui.page, and overwrite some functions. The problem then is that on each page, I have to replace system.web.ui.page with my custompage ...

Moq and parameter attribute inheritance

When I try to mock a class using Moq the method attribute gets inherited to the mock class, but not the parameter attribute. Basically the row "let a = (ArgumentsAttribute) p.GetCustomAttributes(typeof (ArgumentsAttribute), true).SingleOrDefault()" doesnt return the attribute.. Run the code to see where it fails. How do I make this tes...

python: inheriting or composition

Let's say that I have class, that uses some functionality of dict. I used to composite a dict object inside and provide some access from the outside, but recently thought about simply inheriting dict and adding some attributes and methods that I might require. Is it a good way to go, or should I stick to composition? ...

Skip before_filter in Rails

Names and objects have been simplified for clarity's sake. The basic concept reamins the same. I have three controllers: dog, cat, and horse. These controllers all inherit from the controller animal. In the controller animal, I have a before filter that authenticates a user as such: before_filter :authenticate def authenticate authe...