Guest User

Untitled

a guest
Aug 6th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. How to add new Guid to a String List?
  2. public Guid Login(string userName, string password)
  3. {
  4. Guid result = new Guid();
  5.  
  6. if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password))
  7. {
  8. userName = userName.Trim();
  9. password = password.Trim();
  10.  
  11. Member member = BusinessDb.LoginDbJobs.GetUser(userName);
  12.  
  13. if (member != null && member.PasswordDb == password)
  14. {
  15. result = Guid.NewGuid();
  16. Members.Live.Add(result); //--->Object reference not set to an instance of an object.
  17. }
  18. }
  19.  
  20. return result;
  21. }
  22.  
  23. if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password))
  24. {
  25. userName = userName.Trim();
  26. password = password.Trim();
  27.  
  28. Member member = BusinessDb.LoginDbJobs.GetUser(userName);
  29.  
  30. if (member != null && member.PasswordDb == password)
  31. {
  32. result = Guid.NewGuid();
  33. Members.Live.Add(result); //--->Object reference not set to an instance of an object.
  34. }
  35. }
  36.  
  37. return result;
  38. }
  39.  
  40. ...
  41. public class Members
  42. {
  43. public static List< Guid > Live;
  44. }
  45. ...
  46.  
  47. public class Members
  48. {
  49. public static List<Guid> Live = new List<Guid>();
  50. }
  51.  
  52. public class Members
  53. {
  54. public static readonly List<Guid> Live = new List<Guid>();
  55. }
Add Comment
Please, Sign In to add comment