Guest User

Untitled

a guest
Aug 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. ASP.NET C# Bool type casting
  2. bool status1 = (bool)Cache["cache_req_head"];
  3. bool status2 = (bool)Cache["cache_super"];
  4. bool status3 = (bool)Cache["cache_head"];
  5.  
  6. if (checkreqhead == true)
  7. {
  8. Cache["cache_req_head"] = true;
  9. }
  10. else if (checksuper == true)
  11. {
  12. Cache["cache_super"] = true;
  13. }
  14. else if (checkhead == true)
  15. {
  16. Cache["cache_head"] = true;
  17. }
  18.  
  19. bool status1 = (bool)Cache["cache_req_head"];
  20.  
  21. bool status1 = false;
  22. if (Cache["cache_req_head"] != null)
  23. {
  24. status1 = (bool)Cache["cache_req_head"];
  25. }
  26.  
  27. bool? status1 = (bool?)Cache["cache_req_head"];
  28.  
  29. //string is used as an example; you should put the type you expect
  30. string variable = Cache["KEY"] as string;
  31.  
  32. if(variable!=null)
  33. {
  34. // do something
  35. }
Add Comment
Please, Sign In to add comment