using System.Collections.Generic;
static bool stringExist = false;
static void Main(string[] args)
List<object[]> studentList = new List<object[]>() {
new object[]{1, "Петров", "мужской" },
new object[]{2, "Иванов", "мужской" },
new object[]{3, "Сидорова", "женский" },
new object[]{4, "Новикова", "женский" } };
List<object[]> adressList = new List<object[]>() {
new object[]{1, "Ленина 5" },
new object[]{2, "Ленина 2" },
new object[]{3, "Красный проспект 8" },
new object[]{4, "Залесского 10" },};
List<object[]> commonList = MergeLists(studentList, adressList);
ConsoleOutput(commonList);
Console.WriteLine("Какое значение вы хотите заменить? Введите строку.");
var key = Console.ReadLine();
Console.WriteLine("Введите новое значение.");
string newValue = Console.ReadLine();
commonList = ReplaceListValue(key, newValue, commonList);
Console.WriteLine("Новый список:");
ConsoleOutput(commonList);
Console.WriteLine("Список не содержит данной записи.");
private static void ConsoleOutput(List<object[]> commonList)
foreach (object[] note in commonList)
Console.WriteLine(String.Join(", ", note));
private static List<object[]> MergeLists(List<object[]> firstList, List<object[]> secondList)
Dictionary<int, List<object>> dictionary = new Dictionary<int, List<object>>();
AddListDictionary(dictionary, firstList);
AddListDictionary(dictionary, secondList);
List<object[]> commonList = new List<object[]>();
foreach (int key in dictionary.Keys)
commonList.Add(dictionary[key].ToArray());
private static void AddListDictionary(Dictionary<int, List<object>> dictionary, List<object[]> list)
for (int i = 0; i < list.Count; ++i)
int key = (int)list[i][0];
if (!dictionary.ContainsKey(key-1))
dictionary[key - 1] = new List<object>();
foreach(object element in list[i]) dictionary[key - 1].Add(element);
for (int j = 1; j < list[i].Length; ++j)
dictionary[key - 1].Add(list[i][j]);
private static List<object[]> ReplaceListValue (string oldValue, string newValue, List<object[]> list)
foreach (object[] note in list)
for (int i = 1; i < note.Length; i++)
if (note[i].ToString().ToUpper() == oldValue.ToUpper())
note[i] = newValue.ToString();