Wednesday 15 January 2014

Nested Classes C# -


I have data that looks like:

Series 1
image 1 image file 1 < Image 2 ImageFile2
Image3 ImageFile3

Series 2
Image 1 ImageFile 1 - Image 2 ImageFile2
Image 3 ImageFile 3
Image 4 ImageFile4

Series 3
image 1 image file 1

I was trying to list it and use this class:

  Private list & lt; SeriesClass & gt; DCM = new list & lt; Series Class & gt; (); Public Class Series Class {Public Entity Series ID {get; Set; } Public int Value1 {get; Set; } Public String Value2 {get; Set; }} Loop that displays the data {dcm.Add (new series class {Value1 = value1, Value2 = value2, SeriesId = seriesnum}); }   

Clearly all the codes are not included. My result is something that looks like:

Series 1 image1 image file 1
series 1 image file 2 < Series 1 Image 3 ImageFile 3

Series 2 Image 1 ImageFile 1 - Series 2 Image 2 ImageFile 2 - Series 2 Image 3 ImageFile 3 Series 2 Image 4 ImageFile 4 < P> Series 3 image1 imagefile 1

I was thinking that there is a good way to make nests in orbit in which the series ID is the remaining keyfield Committee may become statistics. Like I can pull a list of images under a special series.

I tried to do this:

  public class series class {public int serial id {get; Set; } Public class image class {public int value 1 {receives; Set; } Public String Value2 {get; Set; }}} Loop which depits data {dcm.Add (New Series Class {SeriesClass.ImageClass.Value1 = value1, SeriesClass.ImageClass.Val2 = value2, SeriesClass.SeriesId = seriesnum}); }   

But the list.Anything is not allowed .. Any help would be appreciated. I started working with # yesterday, so this is something new to me if it is a better way to do this with a rugged array or dictionary or something, I am also ready for it.

thanks :)

I believe you use a dictionary Need to use the key as a key and can use ID as a list.

  Personal dictionary & lt; Integer, list & lt; Series Class & gt; & Gt; Dict = new dictionary & lt; Integer, list & lt; Series Class & gt; & Gt; (); Public Class Series Class {Get Public Int Value 1; Set; } Public String Value2 {get; Set; }} Loop which populates data {if (the serial new) of Dikki Contains (Dict [Syringum]). Add (new series class {value1 = value1, value2 = value2}); } And {var list = new list & lt; Series Class & gt; (); List Add (new series class {value1 = value1, value2 = value2}); Dcm.Add (series new, list); }}   

I have tested the code, so syntax errors can happen but I hope you get the summaries. Instead of using TryGet, it may be better.

No comments:

Post a Comment