Skip to content

Instantly share code, notes, and snippets.

@shrayasr
Last active August 29, 2015 14:12
Show Gist options
  • Save shrayasr/c8276014ef9ceb0d4aff to your computer and use it in GitHub Desktop.
Save shrayasr/c8276014ef9ceb0d4aff to your computer and use it in GitHub Desktop.
Programming titbits
// C# | Sorted list, and iterating through them
int value = 1;
SortedList<string, int> sl = new SortedList<string, int>();
sl.add("key", value)
foreach(KeyValuePair<string,int> kv in sl)
{
Console.WriteLine(kv.Key + "=>" + kv.Value);
}
// C# | Get underlying type of a Nullable Object
// http://stackoverflow.com/questions/5644587/find-type-of-nullable-properties-via-reflection
propertyType = Nullable.GetUnderlyingType(propertyType) ?? propertyType
// C# | .toString() format specifiers
// http://msdn.microsoft.com/en-us/library/0c899ak8.aspx
double val = 1.2;
val.toString("#.##"); // prints 1.2
val.toString("0.00"); // prints 1.20
// C# | Attribute classes
// http://www.dotnetperls.com/attribute
[AttributeUsage(AttributeTargets.Class)]
public class route : Attribute { ... }
[route("/")]
public class index { ... }
[route("/customers")]
public class customers { ... }
// SQLServer | Get a whole number if no decimal points are available
select cast(COL_NAME as real) from TABLE_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment