Ask a questionAsk a question
 

AnswerSeparate values from a settings file

  • Friday, November 06, 2009 12:11 AMJoesoft11a Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I have an setting called My_String. In this setting I have 4 values that I need to get and Separate them.

    10,101,http://microsoft.com,1

    string my_value = settings.default.My_string; //this gets the string
    How would I Separate each one and get a returned value for each part.

    I User VC# 2008 Express.


    Toppers BBS http://toppersbbs.dtdns.net

Answers

  • Friday, November 06, 2009 10:37 AMDheeraj_Mallemala Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi, 

        below is the code-snippet.


    string string_to_split = settings.default.My_string;
                char[] delimiter = {','};            
                string[] string_array = string_to_split.Split(delimiter);
                MessageBox.Show(string_array.Length.ToString());
    • Marked As Answer byJoesoft11a Saturday, November 07, 2009 7:34 AM
    •  

All Replies

  • Friday, November 06, 2009 1:14 AMDeborahKMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Use String.Split and split on the commas. This will give you an array containing each comma-demited piece of your string.

    Hope this helps.
    www.insteptech.com ; msmvps.com/blogs/deborahk
    We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
  • Friday, November 06, 2009 2:54 AMJoesoft11a Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Use String.Split and split on the commas. This will give you an array containing each comma-demited piece of your string.

    Hope this helps.
    www.insteptech.com ; msmvps.com/blogs/deborahk
    We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!

    Can you give me a sample of using it.
    Thanks

    Toppers BBS http://toppersbbs.dtdns.net
  • Friday, November 06, 2009 10:37 AMDheeraj_Mallemala Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi, 

        below is the code-snippet.


    string string_to_split = settings.default.My_string;
                char[] delimiter = {','};            
                string[] string_array = string_to_split.Split(delimiter);
                MessageBox.Show(string_array.Length.ToString());
    • Marked As Answer byJoesoft11a Saturday, November 07, 2009 7:34 AM
    •