Now I've found this code.
using Tpm2Lib;
public static void TestTpmVersion()
{
try
{
var tpm = TpmDevice.GetTpm();
var tpmVersion = tpm.GetCapability(Capability.TpmVersion);
if (tpmVersion == 0x20000)
{
Console.WriteLine("TPM version 2.0");
}
else if (tpmVersion == 0x10000)
{
Console.WriteLine("TPM version 1.2");
}
else
{
Console.WriteLine("Unknown TPM version");
}
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
}