Created
August 16, 2018 21:58
-
-
Save peterbucher/0cfa4fa9d62454304184d1f2e0a0e87f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Nullable | |
| DateTime? date = Request.QueryString["date"].ToOrDefault<DateTime?>(); | |
| if(date.HasValue) { | |
| <meinObjekt>.Date = date.Value; | |
| } | |
| // Kein Nullable | |
| Guid guid = Request.Form["userGuid"].ToOrDefault<Guid>(); | |
| if(guid != Guid.Empty) | |
| currentUser = User.Load(guid); | |
| // Standardwert | |
| int width = Request.QueryString["width"].ToOrDefault<int>(1024); | |
| // width == 1024 bei erfolglosem Parsing (Wenn bspw. der Parameter null zurückgibt) | |
| // width == 4 bei erfolgreiem Parsing bei einem Eingangsstring von "4" | |
| // Oder ohne Angabe des Typparameters (Typ wird implizit durch die Angabe des Standardwertes ermittelt) | |
| int height = Request.QueryString["height"].ToOrDefault(768); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment