Adde87a
Member
- Joined
- Jun 17, 2019
- Messages
- 8
- Programming Experience
- Beginner
Hi!
Im in the a course for absolute beginners, trying to learn C# i have a little exprience from Game maker language, so im not totally stupid in this .. but i have a problem right now with some code i cant figure out what im doing wrong.
this is my code
Im getting this error ... I sort if understand i does't like the string, but im not that comfortable with strings and converts yet..
Severity Code Description Project File Line Suppression State
Error CS1503 Argument 1: cannot convert from 'string[]' to 'System.Collections.Generic.IEnumerable<string[]>' ExamProjekt C:\Users\Familjen Svensson\source\repos\ExamProjekt\ExamProjekt\Program.cs 24 Active
Thanks in advance for your time !
Im in the a course for absolute beginners, trying to learn C# i have a little exprience from Game maker language, so im not totally stupid in this .. but i have a problem right now with some code i cant figure out what im doing wrong.
this is my code
C#:
static void Main(string[] args)
{
DateTime showTime = DateTime.Now;
bool ProgramRun = true; // kör programmet
string input = "";
// skapar lista och rum för innehåll TITEL och INLÄGG
string[] post = new string[2];
post[0] = ""; // TITEL
post[1] = ""; // INLÄGG
List<string[]> postBook = new List<string[]>(); // skapar en ny lista för att spara alla inlägg
postBook.AddRange(post);
// setup för meny
bool option; // boolean för TryParse
int menuChoose = 0; // variabel för menyval
{
while (ProgramRun)
{
{
// Skriv ut meny
Console.WriteLine("\n\tVälkommen till loggboken 2019");
Thread.Sleep(100);
Console.WriteLine("[1] - Lägg till logg");
Thread.Sleep(100);
Console.WriteLine("[2] - Öppna logg");
Thread.Sleep(100);
Console.WriteLine("[3] - Sök logg");
Thread.Sleep(100);
Console.WriteLine("[4] - Avsluta");
option = int.TryParse(Console.ReadLine(), out menuChoose);
}
switch (menuChoose) // menyval
{
case 1:
Console.Write("Lägg till i loggen");
for (int i = 0; i < post.Length; i++)
{
input = Console.ReadLine() + showTime;
post[i] = input;
}
break;
case 2:
Console.Clear();
Console.WriteLine("Dina inlägg i loggboken är: ");
foreach (var i in postBook)
{
Console.WriteLine(i);
}
Console.WriteLine("-----");
break;
case 3:
Console.Write("Sök Loggen");
break;
case 4:
Console.WriteLine("Välkommen tillbaka ");
Thread.Sleep(1000);
Console.WriteLine("Ha en bra dag! ");
Thread.Sleep(500);
ProgramRun = false;
break;
default:
Console.Write("Please choose ");
break;
}
}
}
}
Im getting this error ... I sort if understand i does't like the string, but im not that comfortable with strings and converts yet..
Severity Code Description Project File Line Suppression State
Error CS1503 Argument 1: cannot convert from 'string[]' to 'System.Collections.Generic.IEnumerable<string[]>' ExamProjekt C:\Users\Familjen Svensson\source\repos\ExamProjekt\ExamProjekt\Program.cs 24 Active
Thanks in advance for your time !
Last edited by a moderator: