0

C#、Windows 窗体和 Visual Studio 的新手。我已经四处寻找,真的不知道从哪里开始。我已经成功构建了一个简单的 Windows 窗体,它将使用 DateTime.Today 显示日期名称、当前月份、日期,但现在我需要弄清楚如何设置和存储要根据这些变量提取的值。我正在考虑使用数组来存储数据。有人可以让我知道我是否在正确的轨道上。

 Array to store the Months and the data that is associated with each month
 Array to store the Weekday and the data that is associated with each weekday
 Array to store the Days and the data that is associated with each day

然后我要做的就是弄清楚如何提取数组中关联的数据,然后将其设置为将在文本框中显示的变量。如果有人能指出我正确的方向或可能将我链接到一些很好的工作示例,那就太好了。

更新:

这是我用来获取我需要的数据的内容,刚刚从我创建的数组中引用了它

 int cDay = DateTime.Today.Day - 1;
 int cWeekDay = (int)System.Globalization.CultureInfo.InvariantCulture.Calendar.GetDayOfWeek(DateTime.Now) - 1;
 int cMonth = DateTime.Today.Month - 1;

然后我加入了数据使用

 months[cMonth] + weekdays[cWeekDay] + days[cDay];

我创建的数组的月份、工作日、日期在哪里

4

0 回答 0