Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 基于当前月份、日期和工作日名称返回数据_C#_Winforms_Datetime - Fatal编程技术网

C# 基于当前月份、日期和工作日名称返回数据

C# 基于当前月份、日期和工作日名称返回数据,c#,winforms,datetime,C#,Winforms,Datetime,C#、Windows窗体和Visual Studio的新增功能。我到处寻找,真的不知道从哪里开始。我已经成功地构建了一个简单的Windows窗体,它将使用DateTime显示日期、当前月份和日期的名称。今天,我需要弄清楚如何设置和存储基于这些变量提取的值。我在考虑使用数组来存储数据。有人能告诉我我是否走对了路吗 Array to store the Months and the data that is associated with each month Array to store th

C#、Windows窗体和Visual Studio的新增功能。我到处寻找,真的不知道从哪里开始。我已经成功地构建了一个简单的Windows窗体,它将使用DateTime显示日期、当前月份和日期的名称。今天,我需要弄清楚如何设置和存储基于这些变量提取的值。我在考虑使用数组来存储数据。有人能告诉我我是否走对了路吗

 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];

我创建的阵列所在的月份、工作日和天数

您所说的“拉取值”是什么意思?关于您的数据,您告诉我们的还不够多-数据来自哪里?它支持什么样的查询功能?我已经编辑了你的标题。请看“”,其中的共识是“不,他们不应该”。Jon,很抱歉,现在我只想要静态字符串值,而不是我没有真正的线索知道最好的方法。请不要在问题中发布答案。Jon Skeet说得最好,你需要告诉我们正在提取的数据。这将允许我们告诉您如何设置保存数据的最佳方式。可以是一个类、一系列类,或者仅仅是一个字符串数组,但不知道数据是什么,我们就不知所措。
 int cDay = DateTime.Today.Day - 1;
 int cWeekDay = (int)System.Globalization.CultureInfo.InvariantCulture.Calendar.GetDayOfWeek(DateTime.Now) - 1;
 int cMonth = DateTime.Today.Month - 1;