Store String Array In appSettings?

前端 未结 5 1728
借酒劲吻你
借酒劲吻你 2020-11-29 07:57

I\'d like to store a one dimensional string array as an entry in my appSettings. I can\'t simply separate elements with , or | because

5条回答
  •  北海茫月
    2020-11-29 08:55

    For integers I found the following way quicker.

    First of all create a appSettings key with integer values separated by commas in your app.config.

    
    

    Then split and convert the values into int array by using LINQ

    int[] myIntArray =  ConfigurationManager.AppSettings["myIntArray"].Split(',').Select(n => Convert.ToInt32(n)).ToArray();
    

提交回复
热议问题