c# - Providing static variable to parent class -


i want make class tools managing db tables. need somehow send table name tools class data class. managed make work in non-static environment, need make work in static functions.

i did googling, found nothing helpful.

example usage:

caller

user.delete(1); 

tools class

public class dbtools {     public static string table_name = "null";       public static void delete(int id)     {         console.writeline(table_name);     }     ... } 

data class

public class user : dbtools {     public new static string table_name = "users";     ... } 

one option create delete() method in class derived dbtools, , have call base class's delete() method (which still heavy lifting) , pass correct table name.

public class dbtools {     public string table_name = "null";      public void delete(string table_name, int id)     {         console.writeline(table_name);          // whatever work required given table name     } }  public class user : dbtools {     public string table_name = "users";      public void delete(int id)     {         delete(table_name, id);     } } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -