online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
using System; using System.Collections.Generic; using System.Linq; //DateTimeFormatInfo Class (System.Globalization) using System.Globalization; class HelloWorld { static String FORMAT_NUMBER_OF_ENTRIES = "The number of entries is {0}"; static String header = ""; static String log = ""; static void Main() { //mmmeff var months1 = Enumerable.Range(1, 12) .Select ( i => new { monthNumber = i , monthName = DateTimeFormatInfo.CurrentInfo.GetMonthName(i) } ); header = "mmmeff"; Console.WriteLine(header); Console.WriteLine(getHeaderMarker(header)); Console.WriteLine(ToReadable(months1)); Console.WriteLine(""); //Tiago Ávila var months2 = Enumerable.Range(1, 12) .Select ( i => new { monthNumber = i , monthName = DateTimeFormatInfo.CurrentInfo.GetMonthName(i) } ); header = "Tiago Ávila"; Console.WriteLine(header); Console.WriteLine(getHeaderMarker(header)); Console.WriteLine(ToReadable(months2)); Console.WriteLine(""); //SeanH Dictionary<int, string> months3; months3 = Enumerable.Range(1, 12).Select ( i => new KeyValuePair<int, string> ( i , System.Globalization.DateTimeFormatInfo.CurrentInfo.GetMonthName(i) ) ).ToDictionary ( x => x.Key , x => x.Value ); header = "SeanH"; Console.WriteLine(header); Console.WriteLine(getHeaderMarker(header)); Console.WriteLine(months3.ToReadable()); Console.WriteLine(""); //Yona string[] months4 = DateTimeFormatInfo.CurrentInfo.MonthNames; header = "Yona"; Console.WriteLine(header); Console.WriteLine(getHeaderMarker(header)); //techieDelight //Print an array in C# //https://www.techiedelight.com/print-an-array-csharp/ List<string> months4AsList = months4.ToList(); months4AsList.ForEach(Console.WriteLine); log = String.Format(FORMAT_NUMBER_OF_ENTRIES, months4AsList.Count); Console.WriteLine(log); Console.WriteLine(""); //DivineOps var months5 = DateTimeFormatInfo.CurrentInfo.MonthNames .Where ( p=>!string.IsNullOrEmpty(p) ) .Select ( (item, index) => new { monthNumber = index + 1 , monthName = item } ); header = "DivineOps"; Console.WriteLine(header); Console.WriteLine(getHeaderMarker(header)); Console.WriteLine(ToReadable(months5)); Console.WriteLine(""); // Maher Ben Issa // PS: We use the method TakeWhile because the MonthNames array contains a empty 13th month. var months6 = CultureInfo.CurrentCulture.DateTimeFormat.MonthNames .TakeWhile ( m => m != String.Empty ) .Select ( (m,i) => new { monthNumber = i+1 , monthName = m } ) .ToList(); header = "Maher Ben Issa"; Console.WriteLine(header); Console.WriteLine(getHeaderMarker(header)); Console.WriteLine(ToReadable(months6)); Console.WriteLine(""); return; } public static string ToReadable ( IEnumerable<object> list ) { return ( string.Join(Environment.NewLine, list) ); } public static string getHeaderMarker ( string header , char marker = '-' ) { int iLengthofHeader = 0; String strHeaderMarker = ""; iLengthofHeader = header.Length; strHeaderMarker = new String ( marker , iLengthofHeader ); return ( strHeaderMarker ); } } /* https://stackoverflow.com/questions/28552603/stringify-key-value-pairs-in-dictionary */ public static class DictionaryExtensions { public static string ToReadable<T,V> ( this Dictionary<T, V> d ) { return ( string.Join ( Environment.NewLine , d.Select(a => $"{a.Key}: {a.Value}") ) ); } } /* currently unused public static IEnumerable<T> OrderBy<T>(this IEnumerable<T> list, string sortExpression) */ public static class EnumerableExtensions { public static string ToReadableUnused<T,V> ( this IEnumerable<object> list ) { return ( string.Join(Environment.NewLine, list) ); } }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue