2
Answers

Non exceptional case, array out of bounds

Ask a question

I understand that what I'm trying to do is a bit of a hack, but it's interesting nonetheless.

I'm in a situation where it is quite possible that an array might not have as many items as I expect.

Here's the concept:

namespace TESTAPP {     class Program     {         static void Main(string[] args)         {             string derp = "foooooo";             //The split is important, you might not have the character there to split by             Writer(derp.Split('x')[0] ?? ".");             Writer(derp.Split('x')[1] ?? ".");         }          private static void Writer(string writeme)         {             Console.WriteLine(writeme ?? "..");         }     } }

Answers (2)