Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. //Get dynamic time
  2. private float _currentTime =
  3. {
  4.     get
  5.     {
  6.         return SomeClass.SomePublicMethodForCurrentRealTime();
  7.     }
  8. }
  9.  
  10. //A Ternary function (? Operator) to do something like determine day or night
  11. static bool isDay(){
  12.     return _currentTime < 11.59 ? True : False;
  13. }
  14.  
  15. //some function to tick while isDay is True
  16. private void ImDoingDaylightStuff()){
  17.     do
  18.     {
  19.         SomeTickFunctions();
  20.     } while (isDay());
  21. }
  22.  
  23. ///  The ?? (null coalescing) side of the house will run an operation if null or run another if value is present
  24.  
  25. private string _ignoredIfNull = null;
  26. private string _firedIfNotNull = "I'm Not Null";
  27.  
  28. private string SpitOutSomeText()
  29. {
  30.     return _ignoredIfNull ?? _firedIfNotNull;
  31. }
  32. // Output
  33.     "I'm Not Null"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement