Skip to content

Instantly share code, notes, and snippets.

@ivanxpetrov
Created May 18, 2018 04:27
Show Gist options
  • Select an option

  • Save ivanxpetrov/60d62124d5c5cb3d1e8a6de3cbb60555 to your computer and use it in GitHub Desktop.

Select an option

Save ivanxpetrov/60d62124d5c5cb3d1e8a6de3cbb60555 to your computer and use it in GitHub Desktop.
void Main()
{
// Write code to test your extensions here. Press F5 to compile and run.
}
public static class MyExtensions
{
// Write custom extension methods here. They will be available to all queries.
public static IEnumerable<T> Prepend<T>(this IEnumerable<T> sequence, T element) =>
new[] { element }.Concat(sequence);
public static string Stringify<T>(this IEnumerable<T> sequence)
{
if (sequence.Count() == 0)
{
return "Empty";
}
return string.Join(",", sequence);
}
public static T DumpWithCurrentMethodName<T>(this T o, [CallerMemberName] string callerName = "")
{
return o.Dump(callerName);
}
}
// You can also define non-static classes, enums, etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment