It won't even compile and makes no sense at all. Can be
image2.Save(save_to, ImageFormat.Png);
https://msdn.microsoft.com/en-us/library/system.drawing.image%28v=vs.110%29.aspx,
https://msdn.microsoft.com/en-us/library/9t4syfhh%28v=vs.110%29.aspx[
^],
https://msdn.microsoft.com/en-us/library/system.drawing.imaging.imageformat%28v=vs.110%29.aspx,
https://msdn.microsoft.com/en-us/library/system.drawing.imaging.imageformat.png(v=vs.110).aspx.
Note that
ImageFormat.Png
itself is not a string (even if you used string syntax correctly), it is also of the type
ImageFormat
(static read-only property).
Unfortunately, your question clearly shows that you have no clue on how programming works in general, what is source code, compilation, types and instances, properties, all basics like that. I mean, not yet. You can learn all that. Better learn it all before getting to imagine or anything else as advanced or more advanced.
[EDIT]
Variable format? Nothing prevents you from doing it variable. In your code sample, you use the string text,
test
which is only formally variable, but in fact uses
immediate constant in initialization. It makes no difference. You could have a method argument of the type
ImageFormat
and it will make the method's application of the format variable. What you really pass to it, depends on what comes on input. Usually, this is a user's choice, say, via some list box with choice. And there is no preference in storing strings in it. For understanding, please see my past answers:
combobox.selectedvalue shows {} in winform,
How to copy all the items between listboxes in two forms,
Updating listviews on different windows,
wpf modeless dialog and windows, how to communicate,
Sorted listbox with fractional numbers.
—SA