Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems serializing arrays
    primarykey
    data
    text
    <p>So i feel like a noob but this has been baffling me or hours now and although i have read many questions / tutorials i can't seem to get this work. No doubt this is a fundamental problem im running into that is so obvious i'm missing it out completely. Anyway, so the issue i have is this. i have a class which serialises just the way i want it, like so;</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Xml.Serialization; using System.Text; namespace SMCProcessMonitor { public class Config { private string recipient = ""; private int serverport; private string username = ""; private string password = ""; public Config() { } public string Recipient { get { return recipient; } set { recipient= value; } } </code></pre> <p>Followed by gets / sets for the different variables. This works fine but it's the next bit i'm struggling with. Because these deal with just single instances of the code, this was relatively easy, but the next part I wish to add, is a list of programs, presumably looking something like</p> <pre><code>&lt;program&gt; &lt;programname&gt;program1&lt;/programname&gt; &lt;programfilepath&gt;C:/...&lt;/programfilepath&gt; &lt;/program&gt; &lt;program&gt; &lt;programname&gt;program2&lt;/programname&gt; &lt;programfilepath&gt;D:/...&lt;/programfilepath&gt; &lt;/program&gt; </code></pre> <p>I'm assuming here i want to use an array to store the different programs in when serializing, of which I've tried many different ways with no avail, for example. If I create the following class to hold my array details, like so:</p> <pre><code>public class Company { public programs[] Programs; } public class Programs { public string mFileName; public string mFilePath; } </code></pre> <p>So then i come to use this array to fill with data, and call it using the following:</p> <pre><code> SMCProcessMonitor.ConfigManager.mConfigurations.programs = sFile; </code></pre> <p>The left hand side seems fine, but trying to assign it to the variable sFile (which is a string holding a file name) i get several errors (depending on what i try, for example sFile.ToArray and so on, but namely conversion errors such as:</p> <p>Cannot implicitly convert type 'string' to 'SMCProcessMonitor.Config.Programs[]' </p> <p>so with that long winded question asked...anyone have any pointers, or tips as to where im going wrong? like i said im sure its something stupidly basic that im failing to grasp..</p> <p>Cheers in advance, Shane.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload