我有一個名爲CommonImage的靜態類,它具有靜態位圖的屬性,可以隨時獲取。 繼承人我實際類:返回靜態類的所有選定屬性值
public static class CommonImage
{
public static Bitmap AccountConnected { get; }
public static Bitmap AccountDisconnected { get; }
public static Bitmap ArrowDownIcon { get; }
public static Bitmap ArrowUpIcon { get; }
public static Bitmap AutoScrollIcon { get; }
public static Bitmap RSConsDark { get; }
public static Bitmap RSConsLight { get; }
public static Bitmap RSDelDark { get; }
public static Bitmap RSDelLight { get; }
}
什麼我想要做的:
我想獲得所有屬性/形象的startsWith 「RS」並存儲在一個ImageCollection
所有圖像。 並且如果可能的話,沒有像foreach和forloop這樣的循環。
調查反射和linq的組合http://stackoverflow.com/questions/451453/how-to-get-a-static-property-with-反射 – TGH 2014-11-06 05:45:41
+1這使得很多感......感謝提示@TGH – Elegiac 2014-11-06 05:51:31
如果'CommonImage'類是由您創建的,爲什麼您不能只創建返回所需的靜態方法'ImageCollection'? – Fabio 2014-11-06 05:58:55