Though this is possible by using functionality from the .NET System.Reflection API. I beg of you not to do this. Take this route instead by adding all Bitmaps to an array or a list and you can easily iterate over that:
private List<Bitmap> myBitmaps = new List<Bitmap>();
private static readonly Bitmap a1 = new Bitmap(WorkFolder4 + "a1.png");
myBitmap.Add(a1);
private static readonly Bitmap a2 = new Bitmap(WorkFolder4 + "a2.png");
myBitmap.Add(a2);
private static readonly Bitmap a3 = new Bitmap(WorkFolder4 + "a3.png");
myBitmap.Add(a3);
foreach(Bitmap bm in myBitmaps)
{
method(bm);
}
Your method needs to to have a parameter of type Bitmap for this or course. You might also think about having an array / List of the image paths and build a loop over that where you create the bitmaps and call your method:
private List<String> imagePaths = new List<String>();
imagePaths.Add(WorkFolder4 + "a1.png");
imagePaths.Add(WorkFolder4 + "a2.png");
imagePaths.Add(WorkFolder4 + "a3.png");
foreach(String path in imagePaths)
{
Bitmap bm = new Bitmap(path);
method(bm);
}
Unless your method "method" stores or uses the Bitmaps somehow you'd have to put them into an array or a list so you can still access them later. (Does WorkFolder4 end in a backslash?)
Hope this helps! If you have question leave me a comment.
Regards,
Manfred