Autor Beitrag
Felix2000
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 124



BeitragVerfasst: Do 26.05.11 15:58 
Hallo !

Ich habe den folgenden CSharp Code und habe dazu mal eine Frage (diesen Code habe ich nicht selbst geschrieben, sondern muss mich in ein fremdes Programm einarbeiten und bin dazu noch Anfänger in CSharp).

Hier ist der Code:

ausblenden C#-Quelltext
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:
if (File.Exists(currentPath_Project + "RT-Q.bin"))
        {
           IFormatter formatter = new BinaryFormatter();
           Stream serializationStream = new FileStream(currentPath_Project + "RT-Q.bin", FileMode.Open, FileAccess.Read, FileShare.Read);
           Router router = (Router)formatter.Deserialize(serializationStream);
           serializationStream.Close();

           using (StreamWriter writer = new StreamWriter(currentPath_Readed_Values_RT_Q + "RT-Q_bin_"))
           {
               string strCurrentValue = string.Empty;
               foreach (ISDEdifact.ikEintrag isde_difact_router in router.a)
               {
                   if (isde_diface_router != null)
                   {

                       strCurrentValue = isde_difact_router.ikDA_mit.ToString().Trim() + " <> ";
                       strCurrentValue += isde_difact_router.ikDA_ohne.ToString().Trim() + " <> ";
                                                                                   
                       writer.WriteLine(strCurrentValue);
                    }

               }

          } //Ending of Function Using

}


Was genau bedeutet hier die Codezeile: foreach (ISDEdifact.ikEintrag isde_difact_router in router.a)

Besten Dank für die Hilfe !!

Grüße
Felix


Zuletzt bearbeitet von Felix2000 am Do 26.05.11 16:21, insgesamt 2-mal bearbeitet
thepaine91
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 763
Erhaltene Danke: 27

Win XP, Windows 7, (Linux)
D6, D2010, C#, PHP, Java(Android), HTML/Js
BeitragVerfasst: Do 26.05.11 16:09 
Mach da doch BITTE! mal Codetags rum.... kann ja kein Mensch lesen...
Mit [cs] und [/..]
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19326
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 26.05.11 16:36 
In router.a befindet sich eine Liste o.ä. mit Elementen vom Typ ISDEdifact.ikEintrag, die durchgegangen wird. Die einzelnen Einträge kommen dann nacheinander in isde_difact_router und werden entsprechend abgearbeitet.

Das hätte dir aber auch jedes Grundlagenbuch oder -tutorial gesagt...
msdn.microsoft.com/d...ibrary/ttw7t8t6.aspx
huuuuuh
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Do 26.05.11 16:36 
ausblenden C#-Quelltext
1:
foreach (ISDEdifact.ikEintrag isde_difact_router in router.a)					

Für jedes Element isde_difact_router vom Typ ISDEifact.ikEintrag in der Auflistung router.a führe den Codeblock in den geschweiften Klammern aus.
foreach ist also eine Schleife, oft austauschbar gegen eine For-Schleife, die jedes Element einer Auflistung "behandelt". Innerhalb der Schleife ist isde_difact_router eine Referenz auf das aktuell "behandelte" Objekt.
Felix2000 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 124



BeitragVerfasst: Fr 27.05.11 08:51 
Hallo nochmal !

Besten Dank für die Hilfe !

Grüße
Felix2000
Felix2000 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 124



BeitragVerfasst: Mo 22.08.11 08:52 
Hi Folks !

Ich habe nochmal ine Frage zu diesem schon etwas älteren Thema:

ausblenden C#-Quelltext
1:
ISDEdifact.ikEintrag					


Was genau ist das hier, ein Interface oder so?

Greetz
Felix
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19326
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 22.08.11 09:42 
Einfach nur ein bestimmter Typ, was genau (Klasse, ...) ist für die Syntax egal.