.NET Framework introduced in 2001 is a software framework developed by Microsoft that runs primarily on Microsoft Windows.
It includes a large class library named as Framework Class Library (FCL) and provides language interoperability (each language can use code written in other languages) across several programming languages.
Programs written for .NET Framework execute in a software environment (in contrast to a hardware environment) named the Common Language Runtime (CLR).
The CLR is an application virtual machine that provides services such as security, memory management, and exception handling. As such, computer code written using .NET Framework is called "managed code".
FCL and CLR together constitute the .NET Framework.
The latest version of .Net is the .Net Core. This version has the same advantages of the original framework with the difference being that it will work on different platforms and not just Microsoft Windows such as Linux and macOS.
Codewise, there is little difference from the original .Net Framework and older code written on the .Net Framework can be updated to run on .Net Core with minimal changes.
///
/// Get default mac address
///
/// mac Address
public static string DefaultAdapterMacAddress()
{
ManagementClass class2 = new ManagementClass("Win32_NetworkAdapter");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"root\CIMV2",
"SELECT InterfaceIndex, Destination FROM Win32_IP4RouteTable WHERE Destination='0.0.0.0'");
int num = 0;
foreach (ManagementObject obj2 in searcher.Get())
{
num = (int)obj2["InterfaceIndex"];
searcher.Dispose();
}
searcher.Dispose();
string queryString = string.Format("SELECT * FROM Win32_NetworkAdapter WHERE InterfaceIndex={0}", num);
searcher = new ManagementObjectSearcher(@"root\CIMV2", queryString);
string str2 = null;
foreach (ManagementObject obj2 in searcher.Get())
{
str2 = (string)obj2["MACAddress"];
searcher.Dispose();
}
return str2;
}