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. Web Development
  3. ASP.NET
  4. class

class

Scheduled Pinned Locked Moved ASP.NET
question
3 Posts 3 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
    byka
    wrote on last edited by
    #1

    I have public class user where I have all my properties set for user (UserID,Name etc). Now I would like to create a new public class ListAllUser where I would add users with properties from user class. how can I do this?

    M D 2 Replies Last reply
    0
    • B byka

      I have public class user where I have all my properties set for user (UserID,Name etc). Now I would like to create a new public class ListAllUser where I would add users with properties from user class. how can I do this?

      M Offline
      M Offline
      Morgs Morgan
      wrote on last edited by
      #2

      //assuming your class name is called "Users"
      List users = new List();
      Users user = new Users();
      user.UserId = 1;//assuming the id is of type "int"
      user.Name = "Byka";//assuming this is indeed the user name
      users.Add( user );//we are adding an instance of the User class

      You can do this in a for/foreach loop if you are reading the users from the database. if that's the case, you can go

      List users = new List();
      for(int i=0;i

      Happy coding,
      Morgs

      1 Reply Last reply
      0
      • B byka

        I have public class user where I have all my properties set for user (UserID,Name etc). Now I would like to create a new public class ListAllUser where I would add users with properties from user class. how can I do this?

        D Offline
        D Offline
        Dennis E White
        wrote on last edited by
        #3

        excuse me but shouldn't this question really be asked in the language group for whatever language that you are developing with?? how do we know if you are using VB, c#, javascript, or c++??

        as if the facebook, twitter and message boards weren't enough - blogged

        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