=====Initialisation des valeurs===== string[] array = new string[2]; // creates array of length 2, default values string[] array = new string[] { "A", "B" }; // creates populated array of length 2 string[] array = { "A" , "B" }; // creates populated array of length 2 [[http://stackoverflow.com/questions/5678216/all-possible-c-sharp-array-initialization-syntaxes|All possible C# array initialization syntaxes - Stack Overflow]] {{ :lang:csharp:array:c_-_all_possible_array_initialization_syntaxes_-_stack_overflow_2020-04-28_4_53_48_pm_.html |Archive du 15/04/2011 le 28/04/2020}} =====Comparaison de deux tableaux===== return Enumerable.SequenceEqual(tableau1, tableau2); [[http://stackoverflow.com/questions/3232744/easiest-way-to-compare-arrays-in-c-sharp|_net - Easiest way to compare arrays in C# - Stack Overflow]] {{ :lang:csharp:array:net_-_easiest_way_to_compare_arrays_in_c_-_stack_overflow_2020-04-28_4_53_48_pm_.html |Archive du 12/04/2010 le 28/04/2020}} =====Enlever le dernier élément d'une liste===== Array.Resize(ref result, result.Length - 1); [[http://stackoverflow.com/questions/26946196/c-sharp-deleting-last-item-from-array-of-string|C# Deleting Last Item from Array of String - Stack Overflow]] {{ :lang:csharp:array:c_-_deleting_last_item_from_array_of_string_-_stack_overflow_2020-04-28_4_53_46_pm_.html |Archive du 15/11/2014 le 28/04/2020}} =====Ecriture d'un tableau vers un fichier===== File.WriteAllLines("SavedLists.txt", Lists.verbList); [[http://stackoverflow.com/questions/15300572/saving-lists-to-txt-file|c# - Saving lists to txt file - Stack Overflow]] {{ :lang:csharp:array:c_-_saving_lists_to_txt_file_-_stack_overflow_2020-04-28_4_53_45_pm_.html |Archive du 08/03/2013 le 28/04/2020}} =====IndexOf insensible à la casse===== ''Array.IndexOf'' ne permet que du sensible à la casse. Pour du insensible à la casse, il faut passer par une fonction lambda. Array.FindIndex(myarr, t => t.IndexOf(str, StringComparison.InvariantCultureIgnoreCase) >=0); [[https://stackoverflow.com/questions/8935161/how-to-add-a-case-insensitive-option-to-array-indexof|c# - How to add a case-insensitive option to Array.IndexOf - Stack Overflow]] {{ :lang:csharp:array:c_-_how_to_add_a_case-insensitive_option_to_array.indexof_-_stack_overflow_2020-04-28_4_53_46_pm_.html |Archive du 20/01/2012 le 28/04/2020}}