What is a mixed array in C#?

WBOY
Release: 2023-08-23 08:49:34
forward
721 people have browsed it

What is a mixed array in C#?

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}
Copy after login

We can also set them to −

var x = new object[] {87, 33,"tim",6.7, new List<string>() {"football","tennis","squash",&ldquo;cricket&rdquo;} }
Copy after login

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");
Copy after login

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);
      }
   }
}
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template