c# - Convert.ToBase64String() with numbers larger than 255 -


i'm using code below convert list of numbers base64 encoded string.

the problem try on 255 system.overflowexception since overflows byte capacity.

what way of doing this? there example here wondering if there other ways of making work.

private string decimaltobase64(list<int> lst) {     byte[] arr = new byte[lst.count];      for(int = 0; < arr.length; i++)     {         arr[i] = convert.tobyte(lst[i]);     }      return convert.tobase64string(arr); } 

try code:

public static string decimaltobase64(list<int> lst) {     var bytes = new list<byte>();     foreach (var item in lst)         bytes.addrange(bitconverter.getbytes(item));     return convert.tobase64string(bytes.toarray()); } 

read more bytes order wiki


Comments

Popular posts from this blog

how to add preprocess loader in webpack 2 -

python - django admin: changing the way a field (w/ relationship to another model) is submitted on a form so that it can be submitted multiple times -

go - serving up pdfs using golang -