// Load a certificate from a file X509Certificate2 certificate = new X509Certificate2("certificate.pfx", "password"); // Get the effective date as a string string effectiveDateString = certificate.GetEffectiveDateString(); // Print the effective date Console.WriteLine("Effective date: " + effectiveDateString);
// Load a certificate from a byte array byte[] certificateData = File.ReadAllBytes("certificate.cer"); X509Certificate2 certificate = new X509Certificate2(certificateData); // Get the effective date as a string string effectiveDateString = certificate.GetEffectiveDateString(); // Print the effective date Console.WriteLine("Effective date: " + effectiveDateString);This method is part of the `System.Security.Cryptography.X509Certificates` namespace, which is included in the .NET Framework Class Library.