You can use Nmap for that with the option -O for OS detection (see remote OS detection in python).
For .NET, you can use this Nmap wrapper library https://github.com/thomdixon/SaltwaterTaffy, f.e.
It requires you to have Nmap installed and it being in your path.
using SaltwaterTaffy;
using SaltwaterTaffy.Container;
using System;
namespace ScanNetwork
{
class Program
{
public static void Main(string[] args)
{
// target can be a string, an IPAddress or an IEnumerable of either
var target = new Target("192.168.0.0/24");
var scanner = new Scanner(target);
scanner.PersistentOptions = new NmapOptions {
NmapFlag.OsDetection
};
var hosts = scanner.HostDiscovery();
foreach (var host in hosts)
{
Console.WriteLine(host.Address);
foreach(var osMatch in host.OsMatches)
{
Console.WriteLine($"{osMatch.Name} ({osMatch.Family} {osMatch.Generation}) [{osMatch.Certainty}]");
}
}
}
}
}