[英]Check if array have two elements
我正在Xamarin.iOS中開發應用程序以識別照片上的面孔。 我正在使用認知服務和Windows SDK。 當我發送帶有兩個面孔(分別對應兩個不同的人)的照片時,會收到兩個元素數組:
var result = results[0 or 1]
我想知道如何檢查數組是否包含兩個元素(因為在大多數情況下,我只發送一張面孔,所以結果只有一個元素)?
編輯也許我會顯示我的代碼:
var result1 = results[1].Candidates[0].PersonId;
var person = await fsc.GetPersonAsync(personGroupId, result);
Console.WriteLine($"Person indentified is {person.Name}");
results[]
是一個數組,其中返回已識別人員的faceID。 我的意思是,如果我發送帶有2張臉的照片,我將得到帶有results[0]
和results[1]
->的返回信息,其中識別出的人的faceID是哪里。 我想告訴用戶照片上有兩個人。 但是,如果我發送一張返回的臉的照片,則是array results[0]
。
為了找出有多少尺寸,請使用以下代碼。
Console.WriteLine(arr.Rank);
這將返回尺寸數。 我不熟悉您在此處使用的[0 or 1]
語法。
對於真正的二維數組:
string[,] example1 = new string[3, 3] {{"a","b","c"},
{"d","e","f"},
{"g","h","i"} };
Console.WriteLine("Array has {0} dimensions, with {1} x {2} = {3} elements total",
example1.Rank,
example1.GetUpperBound(0) + 1,
example1.GetUpperBound(1) + 1,
example1.Length);
對於具有一個或兩個元素的簡單數組:
string[] example2 = new string[]{"a","b"};
Console.WriteLine("Array has {0} elements.",
example2.Length);
對於鋸齒狀數組:
string[][] example3 = new string[][]{{"a,b,c"},
{"1","2","3","4"}};
Console.WriteLine("Array contains [0] arrays with [1] and [2] elements each",
example3.Length,
example3[0].Length,
example3[1].Length);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.