I have code, which is using System.Net and System.Net.NetworkInformation references, it generates a list of my network connection names.
Everything seems fine and working, but when I made a class of this code, and exported values to listbox1 items add, I had only one network connection name, but really I have four.
How can I solve this problem?
private void button1_Click(object sender, EventArgs e)
{
Adapters obj = new Adapters();
var value = obj.net_adapters();
listBox1.Items.Add(value);
}
public class Adapters
{
public string net_adapters()
{
string value = string.Empty;
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
{
value = nic.Name;
}
return value;
}
}