This is my app.config:
<sectionGroup name="tcpmessage">
<section name="listeningserver" type="System.Configuration.NameValueSectionHandler"/>

<add key="listeningport" value="8008"/>


private void button1_Click(object sender, EventArgs e)

string listeningPort = null;
NameValueCollection config = null;
config = (NameValueCollection)ConfigurationSettings.GetConfig("tcpmessage/listeningserver");
if (config != null)
for (int intKey = 0; intKey <= config.Keys.Count - 1; ++intKey)
if (string.Compare(config.Keys[intKey].ToString(), "listeningport", true) == 0)
listeningPort = config[intKey].ToString();


This works and I can get the listening port value from the app.config, ie. 8008.

However, when I compile with VS 2010, warning said:
Warning 14 'System.Configuration.ConfigurationSettings.GetConfig(string)' is obsolete: '"This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.GetSection"'

How do I change to use ConfigurationManager.GetSection to achieve the same thing?