Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. help to covert this to generic code... [modified]

help to covert this to generic code... [modified]

Scheduled Pinned Locked Moved C#
questionxmljsonhelpannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arbrsoft
    wrote on last edited by
    #1

    //code is like this... [XmlRoot("AutoupData")] public class AutoupData { private ArrayList VersionArray; public AutoupData() { VersionArray = new ArrayList(); } [System.Xml.Serialization.XmlElement("versionInfo")] public VersionC[] VersionInfos { get { VersionC[] VersionInfos = new VersionC[VersionArray.Count]; VersionArray.CopyTo(VersionInfos); return VersionInfos; } set { if (value == null) return; VersionC[] VersionInfos = (VersionC[])value; VersionArray.Clear(); foreach (VersionC Versioninfo in VersionInfos) VersionArray.Add(Versioninfo); } } public int AddItem(VersionC VersionInfo) { return VersionArray.Add(VersionInfo); } } public class VersionC { [XmlAttribute("version")] public float version; public VersionC() { } public VersionC(float Version) { version = Version; } } //code end... is this using boxing and unboxing? if it does then how can I convert this code to generic one? I'm trying hard but the concept is so difficult to me. please help me. thanks.

    C 1 Reply Last reply
    0
    • A arbrsoft

      //code is like this... [XmlRoot("AutoupData")] public class AutoupData { private ArrayList VersionArray; public AutoupData() { VersionArray = new ArrayList(); } [System.Xml.Serialization.XmlElement("versionInfo")] public VersionC[] VersionInfos { get { VersionC[] VersionInfos = new VersionC[VersionArray.Count]; VersionArray.CopyTo(VersionInfos); return VersionInfos; } set { if (value == null) return; VersionC[] VersionInfos = (VersionC[])value; VersionArray.Clear(); foreach (VersionC Versioninfo in VersionInfos) VersionArray.Add(Versioninfo); } } public int AddItem(VersionC VersionInfo) { return VersionArray.Add(VersionInfo); } } public class VersionC { [XmlAttribute("version")] public float version; public VersionC() { } public VersionC(float Version) { version = Version; } } //code end... is this using boxing and unboxing? if it does then how can I convert this code to generic one? I'm trying hard but the concept is so difficult to me. please help me. thanks.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      arbrsoft wrote:

      is this using boxing and unboxing?

      No. VersionC is a class. Only structs cause boxing and unboxing.

      arbrsoft wrote:

      if it does then how can I convert this code to generic one?

      If you are using .NET 2.0 you should look at the Collection classes and then return a ReadOnlyCollection rather than copy arrays around. It might improve your design.


      Upcoming FREE developer events: * Glasgow: db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups