Removed: Rule 4.
string[] lines = File.ReadAllLines("file.txt");
What have you tried?


Tried to loop trough it but i get kinda stuck in the nested loop
Since this seems like a homework question, so I don’t feel comfortable just providing an answer, but I’ll gladly point you in the right direction!
I would encourage you to browse the documentation for the System.IO namespace. This namespace includes classes that are primarily concerned with interfacing with the Windows file system. If you browse through the namespace, you should quickly spot one or two classes that appear useful, and one of them will contain the static methods you need.
Also, remember that when dealing with strings, the System.String class itself IS an enumerable object, so you can treat it like an array of characters. There are several methods in the String class that greatly aid in manipulating strings, such as splitting a line of text into individual words or replacing certain text with other text.
nested string array?
C# devs
null reference exceptions

source