comming from C++ now learning C# and just want to know why this code doesn't work, the output is just a lot of errors, I saw another examples from the Microsoft docs and they use something called var
(specificly when using foreach
) so when I tried to use it, VS tells me the var
datatype doesn't exists(maybe a missing library?) is that the reason why .Skip()
does not work? so Should I use var
? just for writing the first 3 letters of the stack? I really can't tell what is wrong. Actually that suposition I'm making for me is nonsense.. any help is appreciated.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Calendar
{
class days
{
private List <int> numbers_of_days;
private List <String> names_of_days;
public days()
{
numbers_of_days = new List<int>();
names_of_days = new List<string>
{ "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY" };
for (int i = 0; i < 31; i++)
{
numbers_of_days.Add(i);
}
}
public void print_days()
{
foreach (string day in names_of_days)
{
Console.Write(" " + day.Skip(3));
}
Console.Writeline();
}
}
}