using System; namespace Samples { class StringLength { public static void Sample() { string[] words = new string[] { "Apple", "Banana", "Cherry", "Pear", }; CalculateStringLength(words, PrintStingLength); } private static void CalculateStringLength(string[] words, Action callback) { int[] lengths = new int[words.Length]; for (int i = 0; i < words.Length; i++) { lengths[i] = words[i].Length; } if (callback != null) callback(lengths); } private static void PrintStingLength(int[] lengths) { foreach (int length in lengths) { Console.WriteLine(length); } } } }