-1

what is the process for insert value of a in string.format

using System.Windows.Forms;

    namespace NepaliDateConverter
    {
        public partial class Form2 : Form
        {
           static public string[] weeks = { "आईतबार", "सोमबार", "मंगलबार", "बुधबार", "बिहीबार", "शुक्रबार", "शनिबार" };
           int a = (int)DateTime.Now.DayOfWeek;
           **string b= string.Format("{a}", weeks);** 
  • are you stuck at `C# 4.0`? Can you use `C# 6`? – vasily.sib Mar 17 '20 at 03:42
  • What do you want to do? Your `weeks` variable contains a collection of strings, your `string.Format` call puts one thing into a string. Can you show what you'd like as output? You may want to look at the `StringBuilder` class or perhaps the `string.Join` method – Flydog57 Mar 17 '20 at 03:51
  • do you want to have weeks of "a" in a word? let's say day of week is 5, you want to have the fifth data in `weeks` which is "शुक्रबार"? – Luiey Mar 17 '20 at 04:42

1 Answers1

2

String.Format:

string b = string.Format("{0}", weeks[a])

OR

string b = weeks[a];
Backs
  • 24,430
  • 5
  • 58
  • 85