Add array to key in web.config

前端 未结 1 640
谎友^
谎友^ 2021-02-03 22:10

I was wondering if its possible to put an array as a value in a key...example


         


        
相关标签:
1条回答
  • 2021-02-03 22:34

    With ConfigurationManager.AppSettings you can only retrieve scalar values. For your example, if you seperate your emails with a semicolon, you can do:

    string[] emails = ConfigurationManager.AppSettings["email"].Split(';');
    

    with the web.config

    <add key="email" value="email1@email.com;email2@email.com" />
    
    0 讨论(0)
提交回复
热议问题