ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
227
227
EMPFEHLEN
-
Hallo,
wie kann man mit C# eine Variable "erstellen", sodass sie im Prinzip nur ein Zeiger auf eine andere Variable ist, wie z.B. bei der Parameterübergabe mit ref. Dann sollte nähmlich der Code da unten funktionieren.
Code :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
static class Program { [STAThread] static void Main() { int Zahl = 0; Manipulation Man = new Manipulation(ref Zahl); MessageBox.Show(System.Convert.ToString(Zahl)); // Ausgabe = 0 Man.A100(); MessageBox.Show(System.Convert.ToString(Zahl)); // Ausgabe = 100 Man.A3(); MessageBox.Show(System.Convert.ToString(Zahl)); // Ausgabe = 3 Man.A4(); MessageBox.Show(System.Convert.ToString(Zahl)); // Ausgabe = 4 } } class Manipulation { internal int a; public Manipulation(ref int Zahl) { // PROBLEM a = ref Zahl; } public void A3() { a = 3; } public void A4() { a = 4; } public void A100() { a = 100; } }
Ich habe mal im Internet nachgeschaut und bin auf die Klasse System.Reflection.Pointer gestoßen, womit ich aber leider nichts anzufangen wusste.
MfG
Julianprojects-tutorials.de - z.Z. noch im Aufbau...
Ähnliche Themen
-
Richtige Syntax bei Operatorüberladung, wann sind "friend", "const", "&" nötig?
Von mrs_schokokeks im Forum C/C++Antworten: 4Letzter Beitrag: 25.08.10, 19:13 -
Eingabe in der timeline: "time*100" - bei Effekt "turbulentes Versetzen"-"Evolution"
Von MTMonline im Forum Videoschnitt, Videotechnik & -produktionAntworten: 2Letzter Beitrag: 25.04.08, 09:49 -
Wer kann mir helfen, "Tentakeln" bzw. "Schmutz" zu erstellen?
Von DjMG im Forum PhotoshopAntworten: 8Letzter Beitrag: 27.12.05, 13:13 -
"quasi-finally" für funktionen
Von broetchen im Forum .NET CaféAntworten: 9Letzter Beitrag: 25.08.05, 15:00 -
Finder methods + JBoss + Was expecting one of: "CONCAT" "SUBSTRING" ... "(" ... <STRI
Von cengizhdde im Forum Enterprise Java (JEE, J2EE, Spring & Co.)Antworten: 6Letzter Beitrag: 27.05.05, 15:29





Zitieren
Login





