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.");
}
}
}
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
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