Partager via


CollationKey.ToByteArray Method

Definition

Duplicates and returns the value of this CollationKey as a sequence of big-endian bytes terminated by a null.

[Android.Runtime.Register("toByteArray", "()[B", "", ApiSince=24)]
public byte[]? ToByteArray ();
[<Android.Runtime.Register("toByteArray", "()[B", "", ApiSince=24)>]
member this.ToByteArray : unit -> byte[]

Returns

Byte[]

CollationKey value in a sequence of big-endian byte bytes terminated by a null.

Attributes

Remarks

Duplicates and returns the value of this CollationKey as a sequence of big-endian bytes terminated by a null.

If two CollationKeys can be legitimately compared, then one can compare the byte arrays of each to obtain the same result, e.g.

byte key1[] = collationkey1.toByteArray();
            byte key2[] = collationkey2.toByteArray();
            int key, targetkey;
            int i = 0;
            do {
                  key = key1[i] &amp; 0xFF;
                targetkey = key2[i] &amp; 0xFF;
                if (key &lt; targetkey) {
                    System.out.println("String 1 is less than string 2");
                    return;
                }
                if (targetkey &lt; key) {
                    System.out.println("String 1 is more than string 2");
                }
                i ++;
            } while (key != 0 &amp;&amp; targetKey != 0);

            System.out.println("Strings are equal.");

Java documentation for android.icu.text.CollationKey.toByteArray().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to