In my local machine System short Date setting is of format "M/d/yyyy". In my C# code i can convert DateTime to "dd/MM/yyyy" or "dd-MM-yyyy" format using
//1
var date=string.Format("{0:dd/MM/yyyy}", DateTime.Now) //output is:05/09/2017
//2
var date=string.Format("{0:dd-MM-yyyy}", DateTime.Now) //output is:05-09-2017
But if i change my system date settings of short date to "yyyy-MM-dd" or simply any date format having "-" as separator instead of "/" i'm unable to convert date to other formats like
//3
var date=string.Format("{0:dd-MM-yyyy}", DateTime.Now) //output is:05-09-2017
//4
var date=string.Format("{0:dd/MM/yyyy}", DateTime.Now) //output is still :05-09-2017
In the above code even i have changed separator to "/" it's still giving "-" in the output.How can i output 4th one to "05/09/2017".