Figure 1:Output Screen show Adapter name
The previous example (click see) Lab note we use c# find MAC Address only. this example will show how to get Lan card name or Adapter nameSyntax
string NetworkInterfaces.Description
output
Get the description of the network interface.
Example :Get Network Adapter name
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Net.NetworkInformation;
namespace getmac
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
int num_nics=nics.Length;
textBox1.Text += "Totals NIC(s) is " + num_nics + " set(s)";
textBox1.Text += Environment.NewLine;
textBox1.Text += Environment.NewLine;
for (int i=0; i< num_nics; i++)
{
PhysicalAddress mac = nics[i].GetPhysicalAddress();
textBox1.Text += i+") "+mac.ToString();
textBox1.Text += " ("+nics[i].Description+")";
textBox1.Text += Environment.NewLine;
}
}
}
}
Related titles |
Get mac address |
No comments:
Post a Comment