Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7668239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:18:45+00:00 2026-05-31T15:18:45+00:00

So i feel like a noob but this has been baffling me or hours

  • 0

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;

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;
        }
    }

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

<program>
  <programname>program1</programname>
  <programfilepath>C:/...</programfilepath>
</program>
<program>
<programname>program2</programname>
 <programfilepath>D:/...</programfilepath>
</program>

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:

public class Company
{
    public programs[] Programs;
}
public class Programs
{
    public string mFileName;
    public string mFilePath;
}

So then i come to use this array to fill with data, and call it using the following:

        SMCProcessMonitor.ConfigManager.mConfigurations.programs = sFile;

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:

Cannot implicitly convert type ‘string’ to ‘SMCProcessMonitor.Config.Programs[]’

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

Cheers in advance,
Shane.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:18:46+00:00Added an answer on May 31, 2026 at 3:18 pm

    Arrays are a bit cumbersome to use for dynamically sized collections. The easiest way is probably to go for a List, making it look something like;

    public class Company
    {
        public List<Program> Programs = new List<Program>();
    }
    public class Program
    {
        public string FileName;
        public string FilePath;
    }
    

    Adding an entry would then look something like;

    Programs.Add(new Program { FileName = sFile, FilePath = sPath });
    

    …and you can access it using…

    var theFirstProgram = Programs[0];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel like this question ought to have been covered, but I can't seem
I feel like this must have been asked, but I'm unable to find it
I feel like such a noob asking this but, for some reason a horizontal
I feel like I'm so close to working this out and have read dozens
I feel like this question has probably been asked a thousand times already, so
I feel like a real noob asking this, but here's my problem: I want
I feel like a real noob posting this, but I can't seem to find
I feel so noob to ask this. Now, I have rails app that is
I feel like there is an obvious answer to this, but it's been eluding
I feel like this is a very noob question.. but I just can't get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.