This project implements SAM dumping via the registry in C#/.NET.
Most of the code has been directly ported from James Forshaw's awesome book "Windows Security Internals: A Deep Dive into Windows Authentication, Authorization, and Auditing", chapter 10, listings 10.21 to 10.34. You can find James' PowerShell code in the GitHub Repository tyranid/windows-security-internals, where it has been published under the Apache 2.0 License.