![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 654 Pomógł: 17 Dołączył: 19.03.2006 Skąd: z kosmosu ;) Ostrzeżenie: (0%) ![]() ![]() |
Witam, uczę się C# z kursu centrumxp.pl i mam problem z tym kodem (sam napisałem bez pomocy... ale za to jest gdzieś błąd):
Kod using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace TestProgram { class Program { static void Main() { // Variables int[] Numbers = new int[2]; int Match; bool Fail = false; string Action; string ActionName; // What do you want to do? System.Console.WriteLine("Co chcesz zrobic:\n1. Dodac\n2. Odjac\n3. Pomnozyc\n4. Podzielic"); Action = System.Console.ReadLine(); // Get two numbers System.Console.WriteLine("Podaj liczbe nr.1:"); Numbers[0] = System.Convert.ToInt32(System.Console.ReadLine()); System.Console.WriteLine("Podaj liczbe nr.2:"); Numbers[1] = System.Convert.ToInt32(System.Console.ReadLine()); // Selecting action switch (Action) { case "1": ActionName = (string)"dodawania"; Match = Numbers[0] + Numbers[1]; break; case "2": ActionName = (string)"odejmowania"; Match = Numbers[0] - Numbers[1]; break; case "3": ActionName = (string)"mnozenia"; Match = Numbers[0] * Numbers[1]; break; case "4": ActionName = (string)"dzielenia"; Match = Numbers[0] / Numbers[1]; break; default: Fail = true; break; } if (Fail == false) System.Console.WriteLine("Wynik "+ActionName+": "+Match); else System.Console.WriteLine("Nie poprawna akcja wybrana."); } } } Cytat Error 1 Use of unassigned local variable 'ActionName' C:\Documents and Settings\*\Ustawienia lokalne\Dane aplikacji\Temporary Projects\TestProgram\Program.cs 53 51 TestProgram Error 2 Use of unassigned local variable 'Match' C:\Documents and Settings\*\Ustawienia lokalne\Dane aplikacji\Temporary Projects\TestProgram\Program.cs 53 67 TestProgram @edit W C# Mogę używać MySQL? @edit Jaka funkcja sprawdza czy argument jest liczbą/ciągiem itp (PHP: is_string(), is_int(), is_array() itp.)? Dziękuję, Babcia@Stefa Ten post edytował Babcia@Stefa 24.06.2008, 09:40:39 |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 654 Pomógł: 17 Dołączył: 19.03.2006 Skąd: z kosmosu ;) Ostrzeżenie: (0%) ![]() ![]() |
Dzięki nospor działa poprawnie (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
@edit W C# Mogę używać MySQL? @edit Kod using System;
using System.Collections.Generic; using System.Linq; using System.Text; namespace TestProgram { class Program { static void Main() { // Variables int[] Numbers = new int[2]; int Match; bool Fail = false; string Action; string ActionName; // What do you want to do? System.Console.WriteLine("Co chcesz zrobic:\n1. Dodac\n2. Odjac\n3. Pomnozyc\n4. Podzielic"); Action = System.Console.ReadLine(); // Please give the two numbers System.Console.WriteLine("Podaj liczbe nr.1:"); Numbers[0] = System.Convert.ToInt32(System.Console.ReadLine()); System.Console.WriteLine("Podaj liczbe nr.2:"); Numbers[1] = System.Convert.ToInt32(System.Console.ReadLine()); // Selecting action switch (Action) { case "1": ActionName = (string)"dodawania"; Match = Numbers[0] + Numbers[1]; break; case "2": ActionName = (string)"odejmowania"; Match = Numbers[0] - Numbers[1]; break; case "3": ActionName = (string)"mnozenia"; Match = Numbers[0] * Numbers[1]; break; case "4": ActionName = (string)"dzielenia"; Match = Numbers[0] / Numbers[1]; break; default: Fail = true; ActionName = "brak"; Match = 0; break; } if (Fail == false) System.Console.WriteLine("Wynik "+ActionName+": "+Match); else System.Console.WriteLine("Nie poprawna akcja wybrana."); System.Console.Read(); Main(); } } } Ten post edytował Babcia@Stefa 24.06.2008, 09:35:57 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 27.09.2025 - 02:48 |