Autor Beitrag
paddy14
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122



BeitragVerfasst: Di 05.07.11 11:32 
Kenn jemand so ein Array???
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19339
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 05.07.11 11:48 
Warum ein Array? (Auch wenn es auch dort mit dem Typ object geht)
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
            List<object> MyList = new List<object>();
            MyList.Add((Int32)44);
            MyList.Add("fff");
            MessageBox.Show(MyList[0].ToString());
            MessageBox.Show(MyList[1].ToString());
            if (MyList[0is Int32)
                MessageBox.Show("MyList[0] is Int32");
paddy14 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122



BeitragVerfasst: Di 05.07.11 12:19 
Klar warum bin ich nicht selbst darauf gekommen, grr ;)

Danke dir!
Eudaimonie
Hält's aus hier
Beiträge: 14



BeitragVerfasst: Di 05.07.11 13:40 
In demfall kannst du auch gleich die 'ArrayList' nehmen.
Dort kannst du alles reinstopfen, egal welchen Typ es hat.
Trashkid2000
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 561
Erhaltene Danke: 137



BeitragVerfasst: Di 05.07.11 13:59 
Darf man fragen, wozu Du eine Liste bzw. ein Array) benötigst, wo Du alles reinstopfen kannst?
Weniger Typisierung geht echt nicht! Das lässt sich doch bestimmt anders lösen :wink:
pdelvo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 55
Erhaltene Danke: 11



BeitragVerfasst: Do 06.10.11 22:29 
user profile iconEudaimonie hat folgendes geschrieben Zum zitierten Posting springen:
In demfall kannst du auch gleich die 'ArrayList' nehmen.
Dort kannst du alles reinstopfen, egal welchen Typ es hat.


Ist veralltet und im Grunde obsolete. Man sollte die generischen Aufzählungen benutzen.

Mir sieht das ganze nach sehr schlechtem Stil aus. Warum will man strings und ints in die selbe Liste packen?