namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string tekst;
string tekst1;
Console.WriteLine("siemka, podaj jak masz na imię");
tekst = Console.ReadLine();
tekst1 = "lol";
Console.WriteLine(tekst+" " + "Witam CIę");
Console.WriteLine("Zrób to jeszcze raz");
tekst1 = Console.ReadLine();
if (tekst == tekst1)
{
Console.WriteLine("Wpisałeś dwa razy coś innego");
}
else
{
Console.WriteLine("test");
}
Console.ReadLine();
Console.ReadLine();
}
}
}
}
Witam, mam pytanie jak zrobić aby gdy wpiszę 2 imię or ciąg znaków (tekst1) błędnie aby program wracał do 1 linijki Ifa, próbowałem coś stworzyć z While lecz niestety nie mam pojęcia jak to zrobić, są to moje początki więc prosiłbym o łatwe wytłumaczenie co robię nie tak.
Gdy próbowałem zrobić coś z while wyglądało to tak :
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string tekst;
string tekst1;
Console.WriteLine("siemka, podaj jak masz na imię");
tekst = Console.ReadLine();
tekst1 = "lol";
Console.WriteLine(tekst+" " + "Witam CIę");
Console.WriteLine("Zrób to jeszcze raz");
while (tekst == tekst1)
{
tekst1 = Console.ReadLine();
Console.WriteLine("Wpisałeś dwa razy coś innego");
}
Console.ReadLine();
Console.ReadLine();
}
}
}