Tags » Code Snippets

Capturing Multiple Keys

 public static extern int GetKeyboardState(byte[] keystate);
public void HandleKeys()
     byte[] keys = new byte;


     if ((keys[(int)Keys.ControlKey] & keys[(int)Keys.Q] & 128) == 128)

C# ADO.NET Extension Methods

A few useful C# extension methods for working with ADO.NET.

public static class SqlExtensions
    public static SqlParameter ToSqlParameter<T, TProp>(this T obj, Expression<Func<T, TProp>> propertySelector)
        if (propertySelector == null) throw new ArgumentNullException(nameof(propertySelector));
        return obj.ToSqlParameter(((MemberExpression)propertySelector.Body).Member.Name);
    public static SqlParameter ToSqlParameter<T>(this T value, string parameterName)
        if (string.IsNullOrEmpty(parameterName))
            throw new ArgumentException("Value cannot be null or empty.", nameof(parameterName));
        if (value == null)
            return new SqlParameter($"@{parameterName.ToUpper()}", DBNull.Value);
        return new SqlParameter($"@{parameterName.ToUpper()}", value);
    public static SqlParameter ToSqlParameter<T, TProp>(this T?  310 more words

Project Euler #8

Hi all! (lol nobody visits this blog)

Here is problem #8 in all its glory:

The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 529 more words

PowerShell: Writing code snippets in the ISE

This is my scratchpad for a simple talk I’ll be doing on creating code snippets for use in the ISE.




Example with intentional error to show the contrast:


Clothes Changer

In this activity, we will be using the code snippets to make our work faster. The code snippets provides us with many useful ways to manipulate our movie like the mouse click event, drag and drop, and also mobile touch and gesture events like the tap and swipe event. 106 more words