All crypto transactions are made in the smallest value - Wei. But to improve the user experience, on the frontend the transfer amounts are usually inputed in an ETH style. Users want to input value 0.0001 TokenA instead of 100000000000000 Wei TokenA. Standard web3 methods are inconvenient for easy converting. The most convenient conversion method is to use the Moralis.Units helper functions.
Wei is the smallest denomination of ether, and you should always make calculations in Wei and convert only for display reasons.
Due to the limitations of C#(csharp) int and long (32 and 64 bits) bit size been exceeded, BigInteger from using System.Numerics; was used due to it large bit size. int and long can be used but not recommended (long can be used as it is larger than int but it will still be easily exceeded).
// expected output: 5000000000000000000 Wei
// max length = 19
// long length > 19 will yield Overflow Exception error
Converting ERC20 Token to Wei
To convert ERC20 token to Wei, you need to specify the amount of tokens and number of decimals.
//Example: We want to convert 0.5 BUSD. It has 18 decimals