1

Is there an easy way to validate an Ethereum address in C#?

Basically, I am looking for the method that correspond to these ones in Javascript but in C#.

Falcon Stakepool
  • 719
  • 2
  • 5
  • 26

1 Answers1

0

In C#, you can use this method from the Nethereum NuGet package:

/// <summary>
/// Validates if the hex string is 40 alphanumeric characters
/// </summary>
public bool IsValidEthereumAddressHexFormat(string address)
{
    if (string.IsNullOrEmpty(address)) return false;
    return address.HasHexPrefix() && IsValidAddressLength(address) &&
           address.IsHex();
}
Falcon Stakepool
  • 719
  • 2
  • 5
  • 26