Guest User

Untitled

a guest
Feb 23rd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. public class Client(string username, string password, int timeout = 60)
  2.  
  3. class Program
  4. {
  5. private static int? Timeout => GetFromConfig("Timeout");
  6.  
  7. static void Main(string[] args)
  8. {
  9. Client client = new Client(Username, Password, Timeout);
  10. // do things...
  11. }
  12. }
  13.  
  14. static void Main(string[] args)
  15. {
  16. if (Timeout == null)
  17. {
  18. Client client = new Client(Username, Password);
  19. }
  20. else
  21. {
  22. Client client = new Client(Username, Password, Timeout);
  23. }
  24. }
  25.  
  26. public class Client(string username, string password, int? timeout)
  27. {
  28. _timeout = timeout ?? 60;
  29. }
  30.  
  31. public class Client(string username, string password, int? timeout = 60)
  32. {
  33. _timeout = timeout ?? 60;
  34. }
  35.  
  36. static void Main(string[] args)
  37. {
  38. Client client = new Client(Username, Password, Timeout ?? usedefaultparam);
  39. // ...
  40. }
Add Comment
Please, Sign In to add comment