Hallo!
Ich habe folgende Frage:
1.Was habe ich falsch geschrieben ("switch"-Bereich) beim aufrufen Methode "Add"? Compiller schreibt:"Der Name "resultAdd" ist im aktuellen Kontext nicht vorhanden."
2. Zweite Fehler: "ungültiges Token switch.." und "ungültiges Token break...". Was ist hier falsch?
Es sollte eigentlich ein taschenrechner sein(noch nicht ganz fertig).
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87:
| using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace SmalComp { class Program { static void Main(string[] args) {} #region methods private float Add(float firstValue,float secondValue) { float resultAdd = firstValue + secondValue;return resultAdd; } private float Substrah(float fistValue,float secondValue) { } private float Multiply(float firstValue, float secondValue) { } private float Divide(float firstValue, float secondValue) { } #endregion
private float addfirstValue(float firstValue) { Console.WriteLine("The first Small Computer from *lieber Vitalij*"); Console.WriteLine("Geben Sie erste Zahl ein:"); string a = Console.ReadLine(); return float.Parse(a); } private float addSecondvalue(float secondValue) { Console.WriteLine("Geben Sie zweite Zahl ein:"); string b = Console.ReadLine(); return float.Parse(b);
} private int makeChoise(int choise) { Console.WriteLine("Für Addieren drücken Sie die 1","\r\n"); Console.WriteLine("Für Substrahieren drücken Sie 2","\r\n"); Console.WriteLine("Fur Multiplizieren drücken Sie 3","\r\n"); Console.WriteLine("Für Dividieren drücken Sie 4","\r\n"); int choiseline = int.Parse(Console.ReadLine()); return choiseline;
} switch (choise) { case 1 : float endResult = Add(resultAdd); break; case 2 : break; case 3 : break; case 4 : break; default :
break; }
} |
Moderiert von
Christian S.: C#-Tag korrigiert