예제 #1
0
        public static void ExampleGetting()
        {
            Console.WriteLine();
            Console.WriteLine("====== Out Variables - Example Getting ======");

            var dict = new Dictionary <string, string>();

            const string key = "mySecretKey";

            dict.Add(key, "mySecretvalue");

            var values         = new List <string>();
            var valuesUsingOut = new List <string>();

            values.Add(OutVariables.GetDictionaryValue(dict, key));
            values.Add(OutVariables.GetDictionaryValue(dict, "notExistingKey"));

            valuesUsingOut.Add(OutVariables.GetDictionaryValueUsingOut(dict, key));
            valuesUsingOut.Add(OutVariables.GetDictionaryValueUsingOut(dict, "notExistingKey"));

            Log(values);
            Console.WriteLine($"=== NOW USING OUT ===");
            Log(valuesUsingOut);

            Console.WriteLine("====================================================================");
        }
        static async Task Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            OutVariables.ExampleParsing();
            OutVariables.ExampleGetting();
            Discord.ExampleIsANumber();
            VariableLiterals.ExampleLiterals();
            ExpressionBodiedMembersWrapper.ExampleBodiedMembers();
            PatternMatching.ExampleParsing();
            PatternMatching.ExampleJoining();
            LocalFunction.ExampleOddSequence();
            LocalFunction.ExampleFibonacci();
            LocalFunction.ExampleClosestFibonacci();
            await LocalFunction.ExampleAsync();

            StringAsSpan.ExampleIsNullOrEmpty();
            StringAsSpan.ExampleToUpper();
            await MemoryAndSpan.ExampleMemory();

            Ref1Locals.ExampleReplace();
            Ref2Semantics.ExampleSemantics();
            ValueTuples.ExampleTuples();
            ValueTuples.ExampleFibonacci();
            await ValueTask.ExampleTask();
        }
예제 #3
0
        public static void ExampleParsing()
        {
            Console.WriteLine();
            Console.WriteLine("====== Out Variables - Example Parsing ======");

            var test1 = "1.23";
            var test2 = $"1{NumberFormatInfo.CurrentInfo.NumberDecimalSeparator}23";
            var test3 = "1,23";

            var parsedValues         = new List <float>();
            var parsedValuesUsingOut = new List <float>();

            parsedValues.Add(OutVariables.ParseToFloat(test1));
            parsedValues.Add(OutVariables.ParseToFloat(test2));
            parsedValues.Add(OutVariables.ParseToFloat(test3));

            parsedValuesUsingOut.Add(OutVariables.ParseToFloatUsingOut(test1));
            parsedValuesUsingOut.Add(OutVariables.ParseToFloatUsingOut(test2));
            parsedValuesUsingOut.Add(OutVariables.ParseToFloatUsingOut(test3));

            Log(parsedValues);
            Console.WriteLine($"=== NOW USING OUT ===");
            Log(parsedValuesUsingOut);

            var minDouble = Double.MinValue.ToString();
            var maxDouble = Double.MaxValue.ToString();

            ParseToDouble(minDouble);
            ParseToDouble(maxDouble);
            Console.WriteLine($"=== NOW USING OUT ===");
            ParseToDoubleUsingOut(minDouble);
            ParseToDoubleUsingOut(maxDouble);

            Console.WriteLine("====================================================================");
        }