public static void Main()
var vmware = new Computer("VMWare computer");
var hyperV = new Computer("Virtual HyperV compter");
var normalComputer = new Computer("No detectable information.");
Console.WriteLine("Is vmware virtual? " + (vmware.IsVirtual ? " true" : "false"));
Console.WriteLine("Is hyperV virtual? " + (hyperV.IsVirtual ? " true" : "false"));
Console.WriteLine("Is normalComputer virtual? " + (normalComputer.IsVirtual ? " true" : "false"));
public Computer(string systemInfo){
this._systemInfo = systemInfo;
return VirtualDetector.Detect(_systemInfo);
static class VirtualDetector{
public static bool Detect(string systemInfo){
if(CheckHyperV(systemInfo)) return true;
else if(CheckVMWare(systemInfo)) return true;
static bool CheckHyperV(string systemInfo){
if (systemInfo.Contains("HyperV"))
static bool CheckVMWare(string systemInfo){
if (systemInfo.Contains("VMWare"))