• MohamedG's Log

    ?? Operator

    • 0 Comments
    The ?? operator is used to return the left operand if it's not null, otherwise, it returns the right operand. It's equivalent to (left != null ? left : right). string a = null ; object b = a ?? new object (); object c = b ?? "b is null!" ; int ? x...
  • MohamedG's Log

    Code Snippet: switch

    • 0 Comments
    Type sw to select switch: Double tab to expand: Choose the switch_on parameter, in this case I have a parameter of type DayOfWeek (enum): Voilà:
  • MohamedG's Log

    Nullable Value Types

    • 0 Comments
    Can you assign null to int?? Read carefully before you answer, this is a trick question! You can do that by using nullable value types: int? x = null ; To check if the nullable value has a value, you can use the .HasValue property. If the value...
  • MohamedG's Log

    Impersonation

    • 0 Comments
    Impersonation lets you execute code using another user identity. In the WindowsIdentity class, there's a method called Impersonate, it allows you to impersonate the user specified by the WindowsIdentity instance. Just remember to call Undo to get back...
  • MohamedG's Log

    Declare and set properties all at once

    • 2 Comments
    I used to use this technique in ActionScript, and I really like to use it C#: TextBox textBox = new TextBox () { Text = "Hello!" , Enabled = false }; TextBox textBox = new TextBox { Text = "Hello!" , Enabled = false }; // Thanks, kfarmer Point point...
  • MohamedG's Log

    Fiddler

    • 0 Comments
    Don't worry, this post isn't about music or violins, it's about a web debugging proxy. Fiddler is an excellent tool to trace the HTTP/HTTPS traffic and debug it too. It's extensible, it's free, and it's awesome. Try it yourself: http://www.fiddler2.com...
Page 1 of 1 (6 items)