Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道是否可以将数组作为键中的值...示例
<add key="email" value="emails["email1@email.com, email2@email.com"] />
这种语法会起作用吗?
ConfigurationManager.AppSettings您只能检索标量值。对于您的示例,如果您用分号分隔电子邮件,您可以执行以下操作:
ConfigurationManager.AppSettings
string[] emails = ConfigurationManager.AppSettings["email"].Split(';');
使用 web.config
<add key="email" value="email1@email.com;email2@email.com" />