This file contains 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
// LINQPad Example | |
// Updated from http://davefancher.com/2010/04/16/linq-ienumerable-to-datatable/ | |
// Defines an extension method that creates a new System.Data.DataTable from an IEnumerable<T> | |
// Even works with anonymous types | |
public static class IEnumerableExtensions | |
{ | |
public static DataTable ConvertToDataTable<TSource>(this IEnumerable<TSource> source) | |
{ | |
var props = typeof(TSource).GetProperties(); |
This file contains 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
public delegate bool Parser<T>(string s, out T result); | |
public class ParseResult<T> | |
{ | |
internal ParseResult(bool success, T value) | |
{ | |
Success = success; | |
Value = value; | |
} |
This file contains 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
/* | |
# Math Game | |
http://www.umassmed.edu/bsrc/tricks/#days1998 | |
## Instructions | |
1. Pick the number of days a week that you would like to go out (1 - 7). | |
2. Multiply this number by 2. | |
3. Add 5. | |
4. Multiply the new total by 50. |
This file contains 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
public static T SetProperty<T, U>( | |
this T @this, | |
Expression<Func<T, U>> propertyExpression, | |
U value) | |
{ | |
propertyExpression | |
.Body | |
.ConvertTo<MemberExpression>() | |
.Member | |
.Name |