我有一个名为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