How would I add each dates in an array? With the code below I get the first date the first time around then the
second time I get the first and second date. How do I get only the second date the second time and so on. I would like the ShortDateString (only the date no time) Also how do I add these dates into a array.
string[] ArrayNo = new string[31];
foreach (DateTime d in Calendar1.SelectedDates)
{
s += d.ToShortDateString();
Code and Error Messages Below:
foreach (DateTime d in Calendar1.SelectedDates)
{
var ArraNo = Calendar1.SelectedDates.Select(d => ToShortDateString()).ToArrat();
if (Check_Date_Swch == "no")
Process_First_Date = Working_day;
Check_Date_Swch = "yes";
// ArrayNo = ArrayNo + 1;
}
Error Message
Severity Code Description Project File Line Suppression State
Error CS1061 'SelectedDatesCollection' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'SelectedDatesCollection' could be found (are you missing a using directive or an assembly reference?) FirstCWeb C:\Users\Edward\documents\visual studio 2015\Projects\MyFirstCWeb_Solution\FirstCWeb\calendarMonthly.aspx.cs 268 Active
Severity Code Description Project File Line Suppression State
Error CS0136 A local or parameter named 'd' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter FirstCWeb C:\Users\Edward\documents\visual studio 2015\Projects\MyFirstCWeb_Solution\FirstCWeb\calendarMonthly.aspx.cs 268 Active
How would I add each dates in an array? With the code below I get the first date the first time around then the
second time I get the first and second date. How do I get only the second date the second time and so on
"+=" will append the string . You can try to use below code sample :
List<string> list = new List<string>();
foreach (DateTime d in Calendar1.SelectedDates)
{
list.Add(d.ToShortDateString());
} //add these dates into a array
var arrray = list.ToArray();
Member
8 Points
74 Posts
Need help in creating an array and adding dates selected from the Calendar
Oct 13, 2018 12:13 AM|db2tech@yahoo.com|LINK
How would I add each dates in an array? With the code below I get the first date the first time around then the second time I get the first and second date. How do I get only the second date the second time and so on. I would like the ShortDateString (only the date no time) Also how do I add these dates into a array.
string[] ArrayNo = new string[31];
foreach (DateTime d in Calendar1.SelectedDates)
{
s += d.ToShortDateString();
}
Participant
1630 Points
930 Posts
Re: Need help in creating an array and adding dates selected from the Calendar
Oct 14, 2018 06:40 AM|PaulTheSmith|LINK
var ArrayNo = Calendar1.SelectedDates.Select(d => d.ToShortDateString()).ToArrat();
Member
8 Points
74 Posts
Re: Need help in creating an array and adding dates selected from the Calendar
Oct 14, 2018 09:39 AM|db2tech@yahoo.com|LINK
Still need help with the code and message below:
Member
8 Points
74 Posts
Re: Need help in creating an array and adding dates selected from the Calendar
Oct 14, 2018 03:04 PM|db2tech@yahoo.com|LINK
I went around the problem, but I never got the above code to work. I have close the thread.
All-Star
18815 Points
3831 Posts
Re: Need help in creating an array and adding dates selected from the Calendar
Oct 15, 2018 02:36 AM|Nan Yu|LINK
Hi db2tech ,
"+=" will append the string . You can try to use below code sample :
Best Regards,
Nan Yu