sqids / sqids-spec

Sqids specification for encoding multiple numbers into a single ID
https://sqids.org
47 stars 3 forks source link

Update .NET code snippets on the site #12

Closed aradalvand closed 1 year ago

aradalvand commented 1 year ago

This is probably the last time 😅

The return type of the Decode method has changed from int[] to IReadOnlyList<int> (to eliminate unnecessary memory allocation); so the code snippets on the .NET page of the site need to be updated to:

var sqids = new SqidsEncoder<int>();
var id = sqids.Encode(1, 2, 3); // "86Rf07"
var numbers = sqids.Decode(id); // [1, 2, 3]
var sqids = new SqidsEncoder<int>(new()
{
    Alphabet = "FxnXM1kBN6cuhsAvjW3Co7l2RePyY8DwaU04Tzt9fHQrqSVKdpimLGIJOgb5ZE"
});
var id = sqids.Encode(1, 2, 3); // "B4aajs"
var numbers = sqids.Decode(id); // [1, 2, 3]
var sqids = new SqidsEncoder<int>(new()
{
    MinLength = 10
});
var id = sqids.Encode(1, 2, 3); // "86Rf07xd4z"
var numbers = sqids.Decode(id); // [1, 2, 3]
4kimov commented 1 year ago

It's not a problem, thanks for the ping. Updated.