Convert a ushort[] array to a single ushort in C# -
having ushort array, ushort[] how can convert ushort array [44,55] single joined ushort 4455? array has 2 elements.
ushort[] test = new ushort[2]; test[0] = 44; test[1] = 55; // here want convert ushort[] unique ushort value 4455 usortvalue = ? return usortvalue; i expecting .join function string does, it's not possible ushort.
thanks in advance
you can aggregate, predicate being "convert string, concatenate, , parse ushort", sooner or later (sooner!) you're going overflow.
ushort[] test = new ushort[2]; test[0] = 44; test[1] = 55; var result = test.aggregate((p,c) => ushort.parse((p.tostring() + c.tostring()))); live example: http://rextester.com/vkv9570
Comments
Post a Comment