based on given information, e. g. username, or birthdate, whatever. So, for two identical inputs, I need two same output
Why? The point of most SMS confirmations is to confirm the identity of the person initiating a particular action. To this end, it makes no difference what's in the code you send. So long as the receiving user types in what you sent, that's all you need. Also, generating this code deterministically based on other [personal] data is a potential security hole.
I can't store this code in database.
SMS is not a synchronous protocol.
Just because you sent a message doesn't mean that it's been received or even that the user has their phone charged up and switched on at the time. It may be several minutes before the user is in possession of the code you sent and is ready to type it back in.
Where else are you going to store it whilst you're waiting??
GetHashCode returns a unique value for every .Net object within a running application but, as soon as that object goes out of scope and is garbage collected, that value is gone and cannot be recovered.
Unless you store it somewhere.