String.Format variable in concatenated string format
I would like to put a variable in a composite format in String.Format. Value
String str = String.Format("{0:[what should I put here]}", mydate, myFormat};
so the result will depend on myFormat.
myFormat = "yyyy" => str = "2015"
myFormat = "hh:mm:ss" => str = "08:20:20"
I failed to complete
String.Format("{0:{1}}", mydate, myFormat}
and
String.Format("{0:{{1}}}", mydate, myFormat}
and
String.Format("{0:\{1\}}", mydate, myFormat}
Thanks everyone.
+3
source to share