I want to make a class with the methods of the letters of the alphabet. that's what happened:

public class Sort { string[] a = new string[100000]; string[] b = new string[100000]; string[] c = new string[100000]; string[] d = new string[100000]; string[] e = new string[100000]; string[] f = new string[100000]; string[] g = new string[100000]; string[] h = new string[100000]; string[] i = new string[100000]; string[] j = new string[100000]; string[] k = new string[100000]; string[] l = new string[100000]; string[] m = new string[100000]; string[] n = new string[100000]; string[] o = new string[100000]; string[] p = new string[100000]; string[] q = new string[100000]; string[] r = new string[100000]; string[] s = new string[100000]; string[] t = new string[100000]; string[] u = new string[100000]; string[] v = new string[100000]; string[] w = new string[100000]; string[] x = new string[100000]; string[] y = new string[100000]; string[] z = new string[100000]; string field; } 

Now I want to refer to them by the first letter of the line. For example:

 data_sort.((data_sort[i]).Substring(0, 1))[i] = "no"; 

Is it possible on C #?

  • one
    You can Dictionary<> and KeyValue<> - nick_n_a
  • How many words do you want a dictionary? There is a risk to face OutOfMemory. Use subd, or make already "woody" - nick_n_a
  • oh thank you) this is what you need - Yuri Nechaev

1 answer 1

( Removed from comments )

The easiest way to use is Dictionary<char, List<string>> . This will give you the opportunity to search by the first letter, and also uses a dynamic size List<string> , instead of a huge statically allocated array string[100000] .

Your sample code will look something like this:

 char firstLetter = word[0]; List<string> words = dict[firstLetter]; words[i] = "no";