By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,871 Members | 2,368 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,871 IT Pros & Developers. It's quick & easy.

Static Classes And Code Reusability

TRScheel
Expert 100+
P: 638
Platform: Windows Vista
Language: ASPX / C#

I am trying to make a business library for where I work, and I have everything figured out and done except for the ObjectDataSource portion.

If any of you have used the ObjectDataSource, it binds to a static (you could bind it to a class that isnt static, but then the values and items within that class are lost after a different page load) class that has a select, update, delete, and insert method. Now thats all fine and good, but I would like to not have to copy/paste the same code for every project (hence the library... we were reusing a lot of code).

My issue is that I have a good template for the a class to be inherited and used in a project, thus that it has a select, update, insert, and delete functions, in addition to other functions needed, but .NET does not allow static classes to inherit from other static, or non static, classes.

The only viable way I see to make this possible is to do something like this (and mind you, psuedo code):

namespace Library
{
public class DataSetObjectBase
{
private list<object> objects;

public DataReader Select() {}
public void Update(object obj){}
public void Delete(object obj){}
public void Insert(object obj){}
}
}

namespace Project
{
public static class DataSetObject
{
private static Library.DataSetObjectBase base;

public static DataReader Selet() {return base.Select(); }
etc...

}
}

But with the above method it would amost be better to just include a code snippet... I would rather have a solution similiar to:

public static class DataSetObject : DataSetObjectBase
{
private static new list<otherObjects> objects;
}

for instance.. any ideas?

EDIT: Sorry, accidently pressed enter and had it submit before I was done typing
Apr 24 '07 #1
Share this Question
Share on Google+
1 Reply


TRScheel
Expert 100+
P: 638
Everyone is just as equally confused as I am?
Apr 25 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.