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. dictionary

dictionary

Scheduled Pinned Locked Moved C#
csharptutorial
15 Posts 8 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.
  • T toto_2010

    I have classe collectionusing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DLLDOpacimeter { public class CLing { private string codemess; private string format; private string unite; private string taile; private string designtion; private string obligatoir; private bool m_isrequird; private string valeur; private string CRccalcule; private string CRcdonne; private string correct; public CLing(string code, string forma, string unite, string taile, string desingnation, string obligatoi, string valeur1, string CRccalcul, string CRcdonn, string correct, bool m_isrequir) { this.codemess = code; this.format = forma; this.unite = unite; this.taile = taile; this.designtion = desingnation; this.obligatoir = obligatoi; this.valeur = valeur1; this.CRccalcule = CRccalcul; this.CRcdonne = CRcdonn; this.correct = correct; this.m_isrequird = m_isrequir; } public bool _minrequird { get { return m_isrequird; } set { m_isrequird = value; } } public string _valeur { get { return valeur; } set { valeur = value; } } public string _CRccalcule { get { return CRccalcule; } set { CRccalcule = valeur; } } public string _CRcdonn { get { return CRcdonne; } set { CRcdonne = value; } } public string _correct { get { return correct; } set { correct = value; } } public string _codemess { get { return codemess; } set {codemess =value ;} } public string _format { get { return format; } set { format = value; } } public string _unite { get { return unite; } set { unite = value; } } public string _taile { get { return taile; } set { taile = value; } } public string _designtion {

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #6

    TL;DR If you're having trouble serializing a dictionary, that's because it isn't serializable. That, of course, does not prevent you from just writing out the data yourself, in your favourite way. Or maybe your second favourite way, if the default serializer is your favourite. (it kinda sucks though, IMO)

    H 1 Reply Last reply
    0
    • Y yu jian

      I often us the FileStream to read and write the file. the class FileStream is in the namespace, System.IO; :)

      P Offline
      P Offline
      Paul Harsent
      wrote on last edited by
      #7

      Readin the stream, break it up into the bit you want. Asign it into the dic. i.e. textIn = new StreamReader(File); string text = textIn.ReadLine(); var 1 = text.IndexOf("String") var 2 = text.IndexOf("String") var 3 = text.IndexOf("String") Dictionary.Add(Key, new CLing(var1, var2, var3....)) Im unsure what you want. Hopefully this helps.

      T 1 Reply Last reply
      0
      • T toto_2010

        I have classe collectionusing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DLLDOpacimeter { public class CLing { private string codemess; private string format; private string unite; private string taile; private string designtion; private string obligatoir; private bool m_isrequird; private string valeur; private string CRccalcule; private string CRcdonne; private string correct; public CLing(string code, string forma, string unite, string taile, string desingnation, string obligatoi, string valeur1, string CRccalcul, string CRcdonn, string correct, bool m_isrequir) { this.codemess = code; this.format = forma; this.unite = unite; this.taile = taile; this.designtion = desingnation; this.obligatoir = obligatoi; this.valeur = valeur1; this.CRccalcule = CRccalcul; this.CRcdonne = CRcdonn; this.correct = correct; this.m_isrequird = m_isrequir; } public bool _minrequird { get { return m_isrequird; } set { m_isrequird = value; } } public string _valeur { get { return valeur; } set { valeur = value; } } public string _CRccalcule { get { return CRccalcule; } set { CRccalcule = valeur; } } public string _CRcdonn { get { return CRcdonne; } set { CRcdonne = value; } } public string _correct { get { return correct; } set { correct = value; } } public string _codemess { get { return codemess; } set {codemess =value ;} } public string _format { get { return format; } set { format = value; } } public string _unite { get { return unite; } set { unite = value; } } public string _taile { get { return taile; } set { taile = value; } } public string _designtion {

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #8

        Well, it would help if you told the system that some CLing was Serializable for a start. Decorate it with the [Serializable] attribute.

        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

        As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

        My blog | My articles | MoXAML PowerToys | Onyx

        1 Reply Last reply
        0
        • L Lost User

          TL;DR If you're having trouble serializing a dictionary, that's because it isn't serializable. That, of course, does not prevent you from just writing out the data yourself, in your favourite way. Or maybe your second favourite way, if the default serializer is your favourite. (it kinda sucks though, IMO)

          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #9

          harold aptroot wrote:

          If you're having trouble serializing a dictionary, that's because it isn't serializable.

          Oh yes it is![^] Well, sort of. With a bit of effort (and a following wind).

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

          P L 2 Replies Last reply
          0
          • H Henry Minute

            harold aptroot wrote:

            If you're having trouble serializing a dictionary, that's because it isn't serializable.

            Oh yes it is![^] Well, sort of. With a bit of effort (and a following wind).

            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #10

            Henry Minute wrote:

            a following wind

            Some times you just have to provide your own following wind. :~

            1 Reply Last reply
            0
            • H Henry Minute

              harold aptroot wrote:

              If you're having trouble serializing a dictionary, that's because it isn't serializable.

              Oh yes it is![^] Well, sort of. With a bit of effort (and a following wind).

              Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #11

              Hax ;P That's not a dictionary, that's a new class deriving from dictionary :)

              T 1 Reply Last reply
              0
              • L Lost User

                Hax ;P That's not a dictionary, that's a new class deriving from dictionary :)

                T Offline
                T Offline
                toto_2010
                wrote on last edited by
                #12

                exactly but I want to read table from class CLing for Add to dictionary.

                L 1 Reply Last reply
                0
                • T toto_2010

                  exactly but I want to read table from class CLing for Add to dictionary.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #13

                  What do you mean?

                  T 1 Reply Last reply
                  0
                  • L Lost User

                    What do you mean?

                    T Offline
                    T Offline
                    toto_2010
                    wrote on last edited by
                    #14

                    I want to add in dictionary from class deriver .

                    1 Reply Last reply
                    0
                    • P Paul Harsent

                      Readin the stream, break it up into the bit you want. Asign it into the dic. i.e. textIn = new StreamReader(File); string text = textIn.ReadLine(); var 1 = text.IndexOf("String") var 2 = text.IndexOf("String") var 3 = text.IndexOf("String") Dictionary.Add(Key, new CLing(var1, var2, var3....)) Im unsure what you want. Hopefully this helps.

                      T Offline
                      T Offline
                      toto_2010
                      wrote on last edited by
                      #15

                      I want to add in dictionary from class deriver

                      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