Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to access static member??

How to access static member??

Scheduled Pinned Locked Moved C#
questiondatabasetutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jinzhecheng
    wrote on last edited by
    #1

    I have a list definition, public class List { private int index; private string name; } and a table public class Table { public static List List1 = new List(1,"List1"); public static List List2 = new List(2,"List2"); ... } Now , if I want to add a method of Table public class Table { public static List GetListFromIndex( int index){...} } How can I avoid a lot of "switch case"???? Thanks!. I know this maybe related to "reflection" , but cannot figure it out.

    D 1 Reply Last reply
    0
    • J jinzhecheng

      I have a list definition, public class List { private int index; private string name; } and a table public class Table { public static List List1 = new List(1,"List1"); public static List List2 = new List(2,"List2"); ... } Now , if I want to add a method of Table public class Table { public static List GetListFromIndex( int index){...} } How can I avoid a lot of "switch case"???? Thanks!. I know this maybe related to "reflection" , but cannot figure it out.

      D Offline
      D Offline
      DavidNohejl
      wrote on last edited by
      #2

      I don't know background so I must ask, why you dont use standard Array(List) of strings? :confused: I mean (example),

      public class Table
      {
        static ArrayList list;
        public static string GetListFromIndex(int i){return (string)list[i];}
      }
      

      Never forget: "Stay kul and happy" (I.A.)
      David's thoughts / dnhsoftware.org / MyHTMLTidy

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups