Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are mixed arrays in C#?
Mixed arrays are a combination of multi-dimension arrays and jagged arrays.
Note − The mixed arrays type is obsolete now since .NET 4.0 update removed it.
Let us see how you can declare a mixed array −
var x = new object[] {89,45,"jacob",9.8}
We can also set them as −
var x = new object[] {87, 33,"tim",6.7, new List<string>() {"football","tennis","squash",“cricket”} }
Since, mixed arrays are obslete now. For the same work, use the List collection. Here, we have set int and string in the list −
Tuple<int, string> tuple = new Tuple<int, string>(60, "John");
The same example is displayed 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);
}
}
}Advertisements