Created
March 28, 2013 03:52
-
-
Save hatelove/5260444 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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