dictionary
-
You don't use a
Dictionary
to read/write a file. You use a sequence of IO objects to read/write data, theDictionary
is merely a storage vehicle..45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
You don't use a
Dictionary
to read/write a file. You use a sequence of IO objects to read/write data, theDictionary
is merely a storage vehicle..45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001I 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 {
-
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 {
And what is that gibberish? You want me to actually write the code for you?
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
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 {
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)
-
I often us the FileStream to read and write the file. the class FileStream is in the namespace, System.IO; :)
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.
-
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 {
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.
-
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)
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.”
-
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.”
Henry Minute wrote:
a following wind
Some times you just have to provide your own following wind. :~
-
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.”
-
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.