Beispiel #1
0
        private static void WriteFirstIndexOfExamples()
        {
            Console.WriteLine("Examples of overloads of method \"WriteFirstIndexOf\".");

            CustomString str = CustomString.CreateInstance("Hello world".ToCharArray());

            Console.WriteLine($"{nameof(str)} = CreateInstance(\"{str}\")");

            Console.WriteLine($"str.FirstIndexOf('w') => {str.FirstIndexOf('w')}");
            Console.WriteLine($"str.FirstIndexOf('k') => {str.FirstIndexOf('k')}");

            Console.WriteLine($"str.FirstIndexOf('w', 6) => {str.FirstIndexOf('w', 6)}");
            Console.WriteLine($"str.FirstIndexOf('w', 8) => {str.FirstIndexOf('w', 8)}");

            Console.WriteLine($"str.FirstIndexOf('w', 3, 4) => {str.FirstIndexOf('w', 3, 4)}");
            Console.WriteLine($"str.FirstIndexOf('w', 3, 2) => {str.FirstIndexOf('w', 3, 2)}");

            CustomString requiredStr1 = CustomString.CreateInstance("Hello".ToCharArray());
            CustomString requiredStr2 = CustomString.CreateInstance("hello".ToCharArray());
            CustomString requiredStr3 = CustomString.CreateInstance("rl".ToCharArray());
            CustomString requiredStr4 = CustomString.CreateInstance("rld".ToCharArray());

            Console.WriteLine($"str.FirstIndexOf(\"{requiredStr1}\") => {str.FirstIndexOf(requiredStr1)}");
            Console.WriteLine($"str.FirstIndexOf(\"{requiredStr2}\") => {str.FirstIndexOf(requiredStr2)}");
            Console.WriteLine($"str.FirstIndexOf(\"{requiredStr3}\") => {str.FirstIndexOf(requiredStr3)}");
            Console.WriteLine($"str.FirstIndexOf(\"{requiredStr4}\") => {str.FirstIndexOf(requiredStr4)}");

            Console.WriteLine($"str.FirstIndexOf(\"{requiredStr3}\", 0, 9) => {str.FirstIndexOf(requiredStr3, 0, 9)}");
            Console.WriteLine($"str.FirstIndexOf(\"{requiredStr3}\", 0, 8) => {str.FirstIndexOf(requiredStr3, 0, 8)}");

            WriteSeparatorStringsAndAwaitMessage();
        }