Reputation: 2997
I have the following function in c#
public static byte[][] TagSplits(byte[][] splitArray, byte[] original, byte[] guid)
{
byte[] temp;
for (var a = 0; a < splitArray.Length; a++)
{
}
}
I am trying to convert the following code to Kotlin code, I have ended up with the following code:
companion object
{
fun TagSplits(splitArray: ByteArray, original: ByteArray, guid: ByteArray): ByteArray
{
var temp: ByteArray
for(a in 0..splitArray.size)
{
}
}
}
How would I be able to declare a multidimensional byte array in Kotlin as in the c# code base? For the input parameters for the
Upvotes: 1
Views: 795
Reputation: 6466
Arrays do not have special syntax in Kotlin. There are two ways how to work with arrays:
ByteArray
, IntArray
etc. These correspond to Java byte[]
, int[]
arrays.Array<T>
. This corresponds to a Java array of references T[]
.You can achieve the nesting using Array<ByteArray>
, but probably there is a better way of achieving what exactly you need. Alternatives are List<ByteArray>
or a more high-level OOP representation of the byte patterns.
Upvotes: 3
Reputation: 6363
ByteArray
is an object (reference type), so you can create an array of it: Array<ByteArray>
.
Upvotes: 2