Skip to content

Conversation

Cereal-Killa
Copy link
Contributor

@Cereal-Killa Cereal-Killa commented Mar 28, 2022

Based on issue #53.

Usage:

var hashid = new Hashids("123456789");
int id = hashid.DecodeSingle("NkK9");

or

var hashid = new Hashids("123456789");

try
{
    int id = hashid.DecodeSingle("NkK9");
}
catch (MultipleResultsException)
{
    //Handle exception when the hash returns more than one id.
}

or

int id;

if (hashid.TryDecodeSingle("NkK9,NkK9", out id))
{
   Console.WriteLine(id.ToString());
}
else
{
   Console.WriteLine("Invalid Id");
}

The logic same applies to long values: DecodeSingleLong.

image

image

image

@manigandham
Copy link
Collaborator

Thanks @Cereal-Killa @warappa @KeterSCP

@manigandham manigandham merged commit 26861a7 into ullmark:master Mar 30, 2022
@Cereal-Killa Cereal-Killa deleted the single-return branch April 1, 2022 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants