Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i m using a method(int a,int b)

i want parameter should be array index item like method(i[0],i[1]);

but i want this parameter from web config file like
<appsettings>
<key value="{45,54}">


i want i[0]=45 n i[1]=54

how to find this?
Posted
Comments
[no name] 10-Oct-10 15:31pm    
Your question is not clear. What are you getting from the web.config?

1 solution

A quick and dirty way of getting your array filled from web.config would be:

In web.config:

XML
<appSettings>
   <add key="IntegerArrayMembers" value="45,54" />
</appSettings


Then in your code:

int[] integerArray = new List<string>(ConfigurationManager.AppSettings["IntegerArrayMembers"].Split(',')).ConvertAll<int>(s => int.Parse(s)).ToArray();


So you could then call your method with:

method(integerArray[0], integerArray[1]);
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900