Mixed arrays are a combination of multidimensional arrays and irregular arrays.
NOTE: Mixed array types are obsolete since the .NET 4.0 update.
Let's see how to declare a mixed array −
var x = new object[] {89,45,"jacob",9.8}
We can also set them to −
var x = new object[] {87, 33,"tim",6.7, new List<string>() {"football","tennis","squash",“cricket”} }
Since mixed arrays are now deprecated. For the same job, use List collection. Here we have set int and string in list −
Tuple<int, string> tuple = new Tuple<int, string>(60, "John");
The same example is shown below:
using System; using System.Collections.Generic; class Program { static void Main() { // Initializing collections Tuple tuple = new Tuple(99, "Jack"); if (t.Item1 == 99) { Console.WriteLine(tuple.Item1); } } }
The above is the detailed content of What is a mixed array in C#?. For more information, please follow other related articles on the PHP Chinese website!