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 8361519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:43:09+00:00 2026-06-09T11:43:09+00:00

I am trying to split my list of strings at each separate lines using

  • 0

I am trying to split my list of strings at each separate lines using the String.Split method but the both the method below and a regex method did not work. Instead, they returned the following result {0}
0. System.String[]
instead of the actual array of strings. Please help to find the error(s) in the code below:

    string m_settings_temp;
    string[] m_settings;
    public void ShowSettingsGui() {
       var dialog = new OpenFileDialog { Filter = "Data Sources (*.ini)|*.ini*|All Files|*.*" };
       if (dialog.ShowDialog() != DialogResult.OK) return;
       m_settings_temp = File.ReadAllText(dialog.FileName);
       m_settings = m_settings_temp.Split(new [] { '\r', '\n' });
       //This regex method failed as well:  
       //m_settings = Regex.Split(m_settings_temp,"\r\n|\r|\n");
    }

    //The method below is to evaluate the output
    protected override void SolveInstance(IGH_DataAccess DA)
                    {
                        if (m_settings == null)
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "You must declare some valid settings");
                            return;
                        }
                        DA.SetData(0, m_settings);
                    }

Thanks in advance!

  • 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-06-09T11:43:10+00:00Added an answer on June 9, 2026 at 11:43 am

    just use ReadAllLines like this

    m_settings = File.ReadAllLines(dialog.FileName);
    

    this will give you a string[] with an element for each line in the selected file. If, after running this code, m_settings has no elements, the file you selected was empty.


    If I wanted to interrgoate the contents of m_settings in a console app I might do somthing like.

    for (var i = 0; i < m_settings.Length; i ++)
    {
        Console.WriteLine(m_settings[i]);
    }
    

    This would output the content of array, one element at a time. If I used the implementation of ToString for am array, like this,

    Console.WriterLine(m_settings);
    

    I would get a string representation of the array’s type and the number of elements it contains.


    I suspect in your case you want to do somthing like

    protected override void SolveInstance(IGH_DataAccess DA)
    {
         if (m_settings == null || m_settings.Length == 0)
         {
             AddRuntimeMessage(
                  GH_RuntimeMessageLevel.Warning,
                  "You must declare some valid settings");
    
             return;
         }
    
         for (var i = 0; i < m_settings.Length; i ++)
         {
             DA.SetData(i, m_settings[i]);
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to split a string into a int list for further processing. But
Trying to split this string 主楼怎么走 into separate characters (I need an array) using
I am trying to access each element in a List<string> list and split each
I'm trying to split a string on its punctuation, but the string may contain
I am trying to split a string in Javascript using a Regular Expression. My
Hi i was trying to filter a large of text file using Regex.Split with
I am trying to use simple split() method but the output I am getting
I'm trying to split a string: 'QH QD JC KD JS' into a list
I am trying to split Scala list like List(1,2,3,4) into pairs (1,2) (2,3) (3,4)
I am trying to split a string in javascript . it works fine in

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.