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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -