Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp8
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string user1 = "dave";
  14. string pass1 = "123";
  15.  
  16. string user2 = "mike";
  17. string pass2 = "456";
  18.  
  19. string user3 = "john";
  20. string pass3 = "789";
  21.  
  22. string[] users = new string[] { user1, user2, user3 };
  23. string[] passwords = new string[] { pass1, pass2, pass3 };
  24.  
  25. foreach(string user in users)
  26. {
  27. Console.WriteLine("User:"+user);
  28. }
  29. foreach (string pass in passwords)
  30. {
  31. Console.WriteLine("Pass:"+pass);
  32. }
  33.  
  34. User u1 = new User("player1", "pass1");
  35. User u2 = new User("player2", "pass2");
  36. User u3 = new User("player3", "pass3");
  37. // list of objects
  38. List<User> userList = new List<User>();
  39. userList.Add(u1);
  40. userList.Add(u2);
  41. userList.Add(u3);
  42. // remove
  43. userList.Remove(u3);
  44. foreach (User user in userList)
  45. {
  46. user.getUserInfo();
  47. }
  48.  
  49. Console.ReadKey();
  50. }
  51.  
  52. class User
  53. {
  54. // fields/properties
  55. string username;
  56. string password;
  57.  
  58. // constructor
  59. public User(string u, string p)
  60. {
  61. username = u;
  62. password = p;
  63. }
  64.  
  65. // methods
  66. public void getUserInfo()
  67. {
  68. Console.WriteLine("Username: " + username + " Password: " + password);
  69. }
  70. }
  71.  
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement