You can easily get the SharePoint Build Number via C# as shown below.

But, have you ever tried to detect the SharePoint Edition via C#? Well, regardless of the answer, detecting the SharePoint Edition via C# is not just a line of code as Build Number. To detect the SharePoint 2016 Edition, it will require knowing the corresponding SKU. Stock Keeping Unit (SKU) is a unique set of characters’ identification code for a particular product/service. Read more at SKU.

Get SharePoint 2016 Edition via C#
Based on the installed product SKU, you can detect the corresponding SharePoint 2016 Edition programmatically, as the following.

In case, it’s

Output

(Test1) You have SharePoint 2016 installed. The result should look like –
1
(Test2) You don’t have SharePoint 2016 installed but you have other SharePoint version, the result should look like –
2
(Test3) You don’t have any SharePoint version installed, the result should look like –
3