Skip to content

Instantly share code, notes, and snippets.

@hatelove
Created March 28, 2013 03:52
Show Gist options
  • Save hatelove/5260444 to your computer and use it in GitHub Desktop.
Save hatelove/5260444 to your computer and use it in GitHub Desktop.
namespace Utility
{
public static class ExtensionMethod
{
public static int DaysOfThisMonth(this DateTime datetime)
{
return (datetime.AddMonths(1) - datetime).Days;
}
public static bool IsImageFile(this IEnumerable<string> list)
{
string[] imageFormats = {".png", ".jpg", ".gif"};
var result = list.Where(x => Array.IndexOf(imageFormats, GetExt(x)) >= 0);
return result != null && result.Count() == list.Count();
}
private static string GetExt(string value)
{
var index = value.LastIndexOf(".");
return index >= 0 ? value.Substring(index) : string.Empty;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment