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. Dynamic Defination of class

Dynamic Defination of class

Scheduled Pinned Locked Moved C#
helpdata-structures
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.
  • B Offline
    B Offline
    bidisha_tina
    wrote on last edited by
    #1

    I have two arrays name[]={a,b,c} value[]={1,2,3} My requirement is to define a class as myclass/*myclass will contain members as specified by name[] array*/ { string a; string b; string c: } at runtime and to create an object of myclass ,say myobj and set myobj.a=1; myobj.b=2; myobj.c=3; Point to note is that name[] and value[] array can be of any size and contain any value.They are not hard coded. I am at my wit's end to solve this problem.Please help. bidisha

    C 1 Reply Last reply
    0
    • B bidisha_tina

      I have two arrays name[]={a,b,c} value[]={1,2,3} My requirement is to define a class as myclass/*myclass will contain members as specified by name[] array*/ { string a; string b; string c: } at runtime and to create an object of myclass ,say myobj and set myobj.a=1; myobj.b=2; myobj.c=3; Point to note is that name[] and value[] array can be of any size and contain any value.They are not hard coded. I am at my wit's end to solve this problem.Please help. bidisha

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You need C# 3.0, it would handle this, no trouble. Why not use a dictionary to define variables like this ? Christian Graus - Microsoft MVP - C++

      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