System.Console.WriteLine(char)

Here are the examples of the csharp api System.Console.WriteLine(char) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

49 Examples 7

19 View Source File : ConsoleOutput.cs
License : MIT License
Project Creator : bartoszgolek

public void WriteLine(char value)
        {
            Console.WriteLine(value);
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : Big-Endian-32

static void Main(string[] args)
        {
            Console.replacedle = "Marathon Command Line";

            Console.WriteLine
            (
                $"Marathon - Version {Shared.Version.GetInformationalVersion()}\n\n" +
                "" +
                "All your '06 formats are belong to us.\n"
            );

            if (args.Length > 0)
            {
                foreach (string arg in args)
                {
                    // Set compression level.
                    switch (arg)
                    {
                        case "--no-compression":
                            _compressionLevel = CompressionLevel.NoCompression;
                            continue;

                        case "--fast-compression":
                            _compressionLevel = CompressionLevel.Fastest;
                            continue;

                        case "--optimal-compression":
                            _compressionLevel = CompressionLevel.Optimal;
                            continue;
                    }

                    if (Directory.Exists(arg))
                    {
                        U8Archive arc = new(arg, true, _compressionLevel);
                        arc.Save(StringHelper.ReplaceFilename(arg, Path.GetFileName(arg) + arc.Extension));
                    }

                    if (File.Exists(arg))
                    {
                        Console.WriteLine($"File: {arg}\n");

                        // Get last extension for overwritable formats.
                        switch (Path.GetExtension(arg))
                        {
                            case ".arc":
                                U8Archive arc = new(arg, IO.ReadMode.IndexOnly);
                                arc.Extract(Path.Combine(Path.GetDirectoryName(arg), Path.GetFileNameWithoutExtension(arg)));
                                break;

                            case ".lub":
                                LuaBinary lub = new(arg, true);
                                break;
                        }

                        // Get full extension for serialisable formats.
                        switch (StringHelper.GetFullExtension(arg))
                        {
                            case ".bin":
                            case ".bin.json":
                            {
                                Console.WriteLine
                                (
                                    "This file is of a generic type, please specify what format it is;\n" +
                                    "1. Collision (collision.bin)\n" +
                                    "2. Common Package (Common.bin)\n" +
                                    "3. Explosion Package (Explosion.bin)\n" +
                                    "4. Path Package (PathObj.bin)\n" +
                                    "5. Script Package (ScriptParameter.bin)\n" +
                                    "6. Shot Package (ShotParameter.bin)"
                                );

                                switch (Console.ReadKey().KeyChar)
                                {
                                    case '1':
                                        Collision collision = new(arg, true);
                                        break;

                                    case '2':
                                        CommonPackage common = new(arg, true);
                                        break;

                                    case '3':
                                        ExplosionPackage explosion = new(arg, true);
                                        break;

                                    case '4':
                                        PathPackage pathObj = new(arg, true);
                                        break;

                                    case '5':
                                        ScriptPackage scriptParameter = new(arg, true);
                                        break;

                                    case '6':
                                        ShotPackage shotParameter = new(arg, true);
                                        break;
                                }

                                // Pad with two line breaks.
                                Console.WriteLine('\n');

                                break;
                            }

                            case ".bin.obj":
                                Collision collisionOBJ = new(arg, true);
                                break;

                            case ".sbk":
                            case ".sbk.json":
                                SoundBank sbk = new(arg, true);
                                break;

                            case ".epb":
                            case ".epb.json":
                                EventPlaybook epb = new(arg, true);
                                break;

                            case ".tev":
                            case ".tev.json":
                                TimeEvent tev = new(arg, true);
                                break;

                            case ".pkg":
                            case ".pkg.json":
                                replacedetPackage pkg = new(arg, true);
                                break;

                            case ".plc":
                            case ".plc.json":
                                ParticleContainer plc = new(arg, true);
                                break;

                            case ".peb":
                            case ".peb.json":
                                ParticleEffectBank peb = new(arg, true);
                                break;

                            case ".pgs":
                            case ".pgs.json":
                                ParticleGenerationSystem pgs = new(arg, true);
                                break;

                            case ".ptb":
                            case ".ptb.json":
                                ParticleTextureBank ptb = new(arg, true);
                                break;

                            case ".rab":
                            case ".rab.json":
                                ReflectionZone rab = new(arg, true);
                                break;

                            case ".set":
                            case ".set.json":
                                ObjectPlacement set = new(arg, true, !args.Contains("--no-index"));
                                break;

                            case ".prop":
                            case ".prop.json":
                                ObjectPropertyDatabase prop = new(arg, true);
                                break;

                            case string mstEx when mstEx.EndsWith(".mst"):
                            case string mstJsonEx when mstJsonEx.EndsWith(".mst.json"):
                                MessageTable mst = new(arg, true);
                                break;

                            case ".pft":
                            case ".pft.json":
                                PictureFont pft = new(arg, true);
                                break;
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("Arguments:");
                Console.WriteLine("--no-index - disables index display for serialised Object Placement data.");
                Console.WriteLine("--no-compression - writes U8 Archive files uncompressed.");
                Console.WriteLine("--fast-compression - writes U8 Archive files using fast Zlib compression.");
                Console.WriteLine("--optimal-compression - writes U8 Archive files using optimal Zlib compression.\n");

                Console.WriteLine("Archive:");
                Console.WriteLine("- U8 Archive (*.arc)\n");

                Console.WriteLine("Audio:");
                Console.WriteLine("- Sound Bank (*.sbk)\n");

                Console.WriteLine("Event:");
                Console.WriteLine("- Event Playbook (*.epb)");
                Console.WriteLine("- Time Event (*.tev)\n");

                Console.WriteLine("Mesh:");
                Console.WriteLine("- Collision (*.bin)");
                Console.WriteLine("- Reflection Zone (*.rab)\n");

                Console.WriteLine("Package:");
                Console.WriteLine("- replacedet Package (*.pkg)");
                Console.WriteLine("- Common Package (Common.bin)");
                Console.WriteLine("- Explosion Package (Explosion.bin)");
                Console.WriteLine("- Path Package (PathObj.bin)");
                Console.WriteLine("- Script Package (ScriptParameter.bin)");
                Console.WriteLine("- Shot Package (ShotParameter.bin)\n");

                Console.WriteLine("Particle:");
                Console.WriteLine("- Particle Container (*.plc)");
                Console.WriteLine("- Particle Effect Bank (*.peb)");
                Console.WriteLine("- Particle Generation System (*.pgs)");
                Console.WriteLine("- Particle Texture Bank (*.ptb)\n");

                Console.WriteLine("Placement:");
                Console.WriteLine("- Object Placement (*.set)");
                Console.WriteLine("- Object Property Database (*.prop)\n");

                Console.WriteLine("Script:");
                Console.WriteLine("- Lua Bytecode (*.lub)\n");

                Console.WriteLine("Text:");
                Console.WriteLine("- Message Table (*.mst)");
                Console.WriteLine("- Picture Font (*.pft)\n");

                Console.WriteLine
                (
                    "Usage:\n" +
                    "Marathon.CLI.exe \"some_supported_file_format.pkg\" ...\n" +
                    "Marathon.CLI.exe \"some_supported_serialised_format.pkg.json\" ...\n"
                );

                Console.WriteLine("Press any key to continue...");

                Console.ReadKey();
            }
        }

19 View Source File : DeleteCommand.cs
License : MIT License
Project Creator : devlooped

public override Task<int> ExecuteAsync()
        {
            var result = 0;

            var length = Files.Select(x => x.Path).Max(x => x.Length) + 1;
            void writefixed(string s) => Console.Write(s + new string(' ', length - s.Length));

            foreach (var file in Files)
            {
                try
                {
                    if (File.Exists(file.Path))
                        File.Delete(file.Path);

                    var url = Configuration.GetString("file", file.Path, "url");
                    if (url != null)
                        Configuration.RemoveSection("file", file.Path);

                    writefixed(file.Path);
                    Console.WriteLine('✓');
                }
                catch (Exception e)
                {
                    writefixed(file.Path);
                    Console.WriteLine("    x - " + e.Message);
                    result = 1;
                }
            }

            return Task.FromResult(result);
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : dimitarminchev

static void GetMax(char a, char b) 
        {
            var max = a;
            if (b > max) max = b;
            Console.WriteLine(max);
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : dimitarminchev

static void PrintMiddleRow(int n)
        {
            Console.Write('-');
            for (int i = 1; i < n; i++) Console.Write("\\/");
            Console.WriteLine('-');
        }

19 View Source File : TypeField.cs
License : MIT License
Project Creator : GeorgeAlexandria

public void Create()
        {
            Console.WriteLine(System.IO.Path.PathSeparator);
        }

19 View Source File : ArraySegmentTest.cs
License : MIT License
Project Creator : jacking75

[Test]
        public void TestIndexAccess2()
        {
            ArraySegmentList<char> sourceA = new ArraySegmentList<char>();
            List<char> sourceB = new List<char>();

            char[] element = null;

            for (var i = 0; i < 100; i++)
            {
                element = Guid.NewGuid().ToString().ToCharArray();
                sourceA.AddSegment(element, 0, element.Length);
                sourceB.AddRange(element);
            }

            Random rd = new Random();

            for (int i = 0; i < 1000; i++)
            {
                int index = rd.Next(0, sourceA.Count - 1);
                replacedert.AreEqual(sourceB[index], sourceA[index]);
            }

            int testCount = 10000;

            GC.Collect();

            Stopwatch watch = new Stopwatch();

            watch.Start();
            
            char tt = ' ';

            for (var i = 0; i < testCount; i++)
            {
                int index = rd.Next(0, sourceA.Count - 1);
                tt = sourceA[index];
            }

            watch.Stop();

            Console.WriteLine(watch.ElapsedMilliseconds);

            watch.Reset();

            GC.Collect();

            watch.Start();

            for (var i = 0; i < testCount; i++)
            {
                int index = rd.Next(0, sourceA.Count - 1);
                tt = sourceB[index];
            }

            watch.Stop();

            Console.WriteLine(watch.ElapsedMilliseconds);
            Console.WriteLine(tt);
        }

19 View Source File : Program.cs
License : GNU Affero General Public License v3.0
Project Creator : josephworks

public static void Syntax()
        {
            // Use Console.WriteLine to print lines
            Console.WriteLine("Hello World");
            Console.WriteLine(
                "Integer: " + 10 +
                " Double: " + 3.14 +
                " Boolean: " + true);

            // To print without a new line, use Console.Write
            Console.Write("Hello ");
            Console.Write("World");

            ///////////////////////////////////////////////////
            // Types & Variables
            //
            // Declare a variable using <type> <name>
            ///////////////////////////////////////////////////

            // Sbyte - Signed 8-bit integer
            // (-128 <= sbyte <= 127)
            sbyte fooSbyte = 100;
            Console.WriteLine(fooSbyte);

            // Byte - Unsigned 8-bit integer
            // (0 <= byte <= 255)
            byte fooByte = 100;
            Console.WriteLine(fooByte);

            // Short - 16-bit integer
            // Signed - (-32,768 <= short <= 32,767)
            // Unsigned - (0 <= ushort <= 65,535)
            short fooShort = 10000;
            ushort fooUshort = 10000;
            Console.WriteLine(fooShort);
            Console.WriteLine(fooUshort);

            // Integer - 32-bit integer
            int fooInt = 1; // (-2,147,483,648 <= int <= 2,147,483,647)
            uint fooUint = 1; // (0 <= uint <= 4,294,967,295)
            Console.WriteLine(fooInt);
            Console.WriteLine(fooUint);

            // Long - 64-bit integer
            long fooLong = 100000L; // (-9,223,372,036,854,775,808 <= long <= 9,223,372,036,854,775,807)
            ulong fooUlong = 100000L; // (0 <= ulong <= 18,446,744,073,709,551,615)
            Console.WriteLine(fooLong);
            Console.WriteLine(fooUlong);
            // Numbers default to being int or uint depending on size.
            // L is used to denote that this variable value is of type long or ulong

            // Double - Double-precision 64-bit IEEE 754 Floating Point
            double fooDouble = 123.4; // Precision: 15-16 digits
            Console.WriteLine(fooDouble);

            // Float - Single-precision 32-bit IEEE 754 Floating Point
            float fooFloat = 234.5f; // Precision: 7 digits
            Console.WriteLine(fooFloat);
            // f is used to denote that this variable value is of type float

            // Decimal - a 128-bits data type, with more precision than other floating-point types,
            // suited for financial and monetary calculations
            decimal fooDecimal = 150.3m;
            Console.WriteLine(fooDecimal);

            // Boolean - true & false
            bool fooBoolean = true; // or false
            Console.WriteLine(fooBoolean);

            // Char - A single 16-bit Unicode character
            char fooChar = 'A';
            Console.WriteLine(fooChar);

            // Strings -- unlike the previous base types which are all value types,
            // a string is a reference type. That is, you can set it to null
            string fooString = "\"escape\" quotes and add \n (new lines) and \t (tabs)";
            Console.WriteLine(fooString);

            // You can access each character of the string with an indexer:
            char charFromString = fooString[1]; // => 'e'
            // Strings are immutable: you can't do fooString[1] = 'X';

            // Compare strings with current culture, ignoring case
            string.Compare(fooString, "x", StringComparison.CurrentCultureIgnoreCase);

            // Formatting, based on sprintf
            string fooFs = string.Format("Check Check, {0} {1}, {0} {1:0.0}", 1, 2);

            // Dates & Formatting
            DateTime fooDate = DateTime.Now;
            Console.WriteLine(fooDate.ToString("hh:mm, dd MMM yyyy"));

            // Verbatim String
            // You can use the @ symbol before a string literal to escape all characters in the string
            string path = "C:\\Users\\User\\Desktop";
            string verbatimPath = @"C:\Users\User\Desktop";
            Console.WriteLine(path == verbatimPath);  // => true

            // You can split a string over two lines with the @ symbol. To escape " use ""
            string bazString = @"Here's some stuff
on a new line! ""Wow!"", the mreplacedes cried";
            Console.WriteLine(bazString);

            // Use const or read-only to make a variable immutable
            // const values are calculated at compile time
            const int hoursWorkPerWeek = 9001;
            Console.WriteLine(hoursWorkPerWeek);

            ///////////////////////////////////////////////////
            // Data Structures
            ///////////////////////////////////////////////////

            // Arrays - zero indexed
            // The array size must be decided upon declaration
            // The format for declaring an array is follows:
            // <datatype>[] <var name> = new <datatype>[<array size>];
            int[] intArray = new int[10];

            // Another way to declare & initialize an array
            int[] y = { 9000, 1000, 1337 };

            // Indexing an array - Accessing an element
            Console.WriteLine("intArray @ 0: " + intArray[0]);
            // Arrays are mutable.
            intArray[1] = 1;

            // Lists
            // Lists are used more frequently than arrays as they are more flexible
            // The format for declaring a list is follows:
            // List<datatype> <var name> = new List<datatype>();
            List<int> intList = new List<int>();
            List<string> stringList = new List<string>();
            List<int> z = new List<int> { 9000, 1000, 1337 }; // initialize
            // The <> are for generics - Check out the cool stuff section

            // Lists don't default to a value;
            // A value must be added before accessing the index
            intList.Add(1);
            Console.WriteLine("intList @ 0: " + intList[0]);

            // Others data structures to check out:
            // Stack/Queue
            // Dictionary (an implementation of a hash map)
            // HashSet
            // Read-only Collections
            // Tuple (.Net 4+)

            ///////////////////////////////////////
            // Operators
            ///////////////////////////////////////
            Console.WriteLine("\n->Operators");

            int i1 = 1, i2 = 2; // Shorthand for multiple declarations

            // Arithmetic is straightforward
            Console.WriteLine(i1 + i2 - i1 * 3 / 7); // => 3

            // Modulo
            Console.WriteLine("11%3 = " + (11 % 3)); // => 2

            // Comparison operators
            Console.WriteLine("3 == 2? " + (3 == 2)); // => false
            Console.WriteLine("3 != 2? " + (3 != 2)); // => true
            Console.WriteLine("3 > 2? " + (3 > 2)); // => true
            Console.WriteLine("3 < 2? " + (3 < 2)); // => false
            Console.WriteLine("2 <= 2? " + (2 <= 2)); // => true
            Console.WriteLine("2 >= 2? " + (2 >= 2)); // => true

            // Bitwise operators!
            /*
            ~       Unary bitwise complement
            <<      Signed left shift
            >>      Signed right shift
            &       Bitwise AND
            ^       Bitwise exclusive OR
            |       Bitwise inclusive OR
            */

            // Incrementations
            int i = 0;
            Console.WriteLine("\n->Inc/Dec-rementation");
            Console.WriteLine(i++); //Prints "0", i = 1. Post-Incrementation
            Console.WriteLine(++i); //Prints "2", i = 2. Pre-Incrementation
            Console.WriteLine(i--); //Prints "2", i = 1. Post-Decrementation
            Console.WriteLine(--i); //Prints "0", i = 0. Pre-Decrementation

            ///////////////////////////////////////
            // Control Structures
            ///////////////////////////////////////
            Console.WriteLine("\n->Control Structures");

            // If statements are c-like
            int j = 10;
            if (j == 10)
            {
                Console.WriteLine("I get printed");
            }
            else if (j > 10)
            {
                Console.WriteLine("I don't");
            }
            else
            {
                Console.WriteLine("I also don't");
            }

            // Ternary operators
            // A simple if/else can be written as follows
            // <condition> ? <true> : <false>
            int toCompare = 17;
            string isTrue = toCompare == 17 ? "True" : "False";

            // While loop
            int fooWhile = 0;
            while (fooWhile < 100)
            {
                // Iterated 100 times, fooWhile 0->99
                fooWhile++;
            }

            // Do While Loop
            int fooDoWhile = 0;
            do
            {
                // Start iteration 100 times, fooDoWhile 0->99
/*
                if (false)
                    continue; // skip the current iteration
*/

                fooDoWhile++;

                if (fooDoWhile == 50)
                    break; // breaks from the loop completely
            } while (fooDoWhile < 100);

            // for loop structure => for(<start_statement>; <conditional>; <step>)
            for (int fooFor = 0; fooFor < 10; fooFor++)
            {
                // Iterated 10 times, fooFor 0->9
            }

            // For Each Loop
            // foreach loop structure => foreach(<iteratorType> <iteratorName> in <enumerable>)
            // The foreach loop loops over any object implementing IEnumerable or IEnumerable<T>
            // All the collection types (Array, List, Dictionary...) in the .Net framework
            // implement one or both of these interfaces.
            // (The ToCharArray() could be removed, because a string also implements IEnumerable)
            foreach (char character in "Hello World".ToCharArray())
            {
                // Iterated over all the characters in the string
            }

            // Switch Case
            // A switch works with the byte, short, char, and int data types.
            // It also works with enumerated types (discussed in Enum Types),
            // the String clreplaced, and a few special clreplacedes that wrap
            // primitive types: Character, Byte, Short, and Integer.
            //int month = 3;
            //string monthString;
            //switch (month)
            //{
            //    case 1:
            //        monthString = "January";
            //        break;

            //    case 2:
            //        monthString = "February";
            //        break;

            //    case 3:
            //        monthString = "March";
            //        break;
            //    // You can replacedign more than one case to an action
            //    // But you can't add an action without a break before another case
            //    // (if you want to do this, you would have to explicitly add a goto case x
            //    case 6:
            //    case 7:
            //    case 8:
            //        monthString = "Summer time!!";
            //        break;

            //    default:
            //        monthString = "Some other month";
            //        break;
            //}

            ///////////////////////////////////////
            // Converting Data Types And Typecasting
            ///////////////////////////////////////

            // Converting data

            // Convert String To Integer
            // this will throw a FormatException on failure
            int.Parse("123"); // returns an integer version of "123"

            // try parse will default to type default on failure
            // in this case: 0
            int tryInt;
            if (int.TryParse("123", out tryInt)) // Function is boolean
                Console.WriteLine(tryInt);       // 123

            // Convert Integer To String
            // Convert clreplaced has a number of methods to facilitate conversions
            Convert.ToString(123);
            // or
            tryInt.ToString();

            // Casting
            // Cast decimal 15 to an int
            // and then implicitly cast to long
            long x = (int)15M;
            Console.WriteLine(x);
        }

19 View Source File : Class1.cs
License : MIT License
Project Creator : JoshuaWierenga

private static void ConsoleReadMirror()
        {
            while (true)
            {
                //Console.Write("Input: ");
                int input = Console.Read();

                Console.Write("\r\nReceived: ");
                Console.WriteLine((char)input);

                /*if (input == '\n')
                {
                    Console.WriteLine();
                }
                else
                {
                    Console.Write(", ");
                }*/

                for (ulong i = 0; i < int.MaxValue; i++)
                {

                }
            }
        }

19 View Source File : YesNoQuestion.cs
License : GNU General Public License v3.0
Project Creator : lastunicorn

private YesNoAnswer ReadAnswerInternal()
        {
            while (true)
            {
                ConsoleKeyInfo consoleKeyInfo = Console.ReadKey(true);

                if (consoleKeyInfo.Key == AcceptDefaultKey && DefaultAnswer.HasValue)
                {
                    string defaultText;

                    switch (DefaultAnswer.Value)
                    {
                        case YesNoAnswer.Yes:
                            defaultText = YesText;
                            break;

                        case YesNoAnswer.No:
                            defaultText = NoText;
                            break;

                        case YesNoAnswer.Cancel:
                            defaultText = CancelText;
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                    }

                    Console.WriteLine(defaultText);
                    return DefaultAnswer.Value;
                }

                if (AcceptCancel)
                {
                    if (consoleKeyInfo.Key == CancelKey)
                    {
                        Console.WriteLine(consoleKeyInfo.KeyChar);
                        return YesNoAnswer.Cancel;
                    }

                    if (AcceptEscapeAsCancel && consoleKeyInfo.Key == ConsoleKey.Escape)
                    {
                        Console.WriteLine(YesNoQuestionResources.QuestionCanceled);
                        return YesNoAnswer.Cancel;
                    }
                }

                if (consoleKeyInfo.Key == YesKey)
                {
                    Console.WriteLine(consoleKeyInfo.KeyChar);
                    return YesNoAnswer.Yes;
                }

                if (consoleKeyInfo.Key == NoKey)
                {
                    Console.WriteLine(consoleKeyInfo.KeyChar);
                    return YesNoAnswer.No;
                }
            }
        }

19 View Source File : SystemConsole.cs
License : MIT License
Project Creator : lechu445

public void WriteLine(char value)
      => Console.WriteLine(value);

19 View Source File : ForEach.cs
License : MIT License
Project Creator : maniero

public static void Main() {
        int[] array = new int[]{1, 2, 3, 4, 5, 6};
        foreach (int item in array) {
            WriteLine(item);
        }
        var lista = new List<int>{1, 2, 3, 4, 5, 6};
        foreach (int item in lista) {
            WriteLine(item);
        }
        var texto = "123456";
        foreach (char item in texto) {
            WriteLine(item);
        }
    }

19 View Source File : IntToChar.cs
License : MIT License
Project Creator : maniero

public static void Main() {
		var x = 2;
		WriteLine(ToChar(x + 48));
	}

19 View Source File : UnderlayingChar.cs
License : MIT License
Project Creator : maniero

public static void Main() {
		WriteLine(PayCode.NotPaid.GetTypeCode());
		WriteLine((int)(PayCode.NotPaid));
		WriteLine((char)(PayCode.NotPaid));
		Teste('A');
		int x = 'B';
	}

19 View Source File : JustOneChar.cs
License : MIT License
Project Creator : maniero

public static void Main() {
        string frase = "Diego lima de Aquino";
        for (int i = frase.Length - 1; i >= 0; i--) WriteLine(frase[i]);
	}

19 View Source File : Substring.cs
License : MIT License
Project Creator : maniero

static void Main() {
        var url = "http://abc.com";
        var posicao = url.IndexOf(':');
        if (posicao < 0) return; //aqui você trata como quiser se não achar a string
        WriteLine(url.Substring(posicao));
        WriteLine(url[posicao..]); //só para C# 8
    }

19 View Source File : SimpleTextEditor.cs
License : GNU General Public License v3.0
Project Creator : martinmladenov

public static void Main()
        {
            Stack<string> history = new Stack<string>();
            history.Push(string.Empty);

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                var split = Console.ReadLine().Split();
                int command = int.Parse(split[0]);

                if (command == 1)
                {
                    history.Push(history.Peek() + split[1]);
                }
                else if (command == 2)
                {
                    var oldLine = history.Peek();
                    history.Push(oldLine.Substring(0, oldLine.Length - int.Parse(split[1])));
                }
                else if (command == 3)
                {
                    Console.WriteLine(history.Peek()[int.Parse(split[1]) - 1]);
                }
                else if (command == 4 && history.Count > 1)
                {
                    history.Pop();
                }
            }
        }

19 View Source File : 03. Latin Letters.cs
License : GNU General Public License v3.0
Project Creator : martinmladenov

static void Main(string[] args)
        {

            for (char i = 'a'; i <= 'z'; i++)
            {
                Console.WriteLine(i);
            }

        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : martinmladenov

static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < (n + 1) / 2; i++)
            {
                int stars = 2 * i + (n % 2 == 0 ? 2 : 1);
                Console.Write(new string('-', (n - stars) / 2));
                Console.Write(new string('*', stars));
                Console.WriteLine(new string('-', (n - stars) / 2));
            }
            for (int i = 0; i < n / 2; i++)
            {
                Console.Write('|');
                Console.Write(new string('*', n - 2));
                Console.WriteLine('|');

            }
        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : martinmladenov

static void Main(string[] args)
        {
            char firstBoatChar = char.Parse(Console.ReadLine());
            char secondBoatChar = char.Parse(Console.ReadLine());
            int n = int.Parse(Console.ReadLine());

            int firstBoatTiles = 0;
            int secondBoatTiles = 0;

            for (int i = 1; i <= n ; i++)
            {
                string input = Console.ReadLine();
                if (input == "UPGRADE")
                {
                    firstBoatChar += (char)3;
                    secondBoatChar += (char)3;
                    continue;
                }
                if (i % 2 == 1)
                    firstBoatTiles += input.Length;
                else
                    secondBoatTiles += input.Length;

                if(firstBoatTiles >= 50 || secondBoatTiles >= 50)
                    break;
            }

            Console.WriteLine(firstBoatTiles > secondBoatTiles ? firstBoatChar : secondBoatChar);
        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : martinmladenov

private static void PrintMiddleRow(int n)
        {
            Console.Write('-');
            for (int i = 0; i < n - 1; i++)
            {
                Console.Write("\\/");
            }

            Console.WriteLine('-');
        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : martinmladenov

static void Main(string[] args)
        {
            string s1 = Console.ReadLine();
            char c1 = char.Parse(Console.ReadLine());
            char c2 = char.Parse(Console.ReadLine());
            char c3 = char.Parse(Console.ReadLine());
            string s2 = Console.ReadLine();

            Console.WriteLine(s1);
            Console.WriteLine(c1);
            Console.WriteLine(c2);
            Console.WriteLine(c3);
            Console.WriteLine(s2);
        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : martinmladenov

private static void Main(string[] args)
        {
            string type = Console.ReadLine();
            switch (type)
            {
                case "string":
                    {
                        string a = Console.ReadLine();
                        string b = Console.ReadLine();
                        Console.WriteLine(GetMax(a, b));
                        break;
                    }
                case "char":
                    {
                        char a = char.Parse(Console.ReadLine());
                        char b = char.Parse(Console.ReadLine());
                        Console.WriteLine(GetMax(a, b));
                        break;
                    }
                case "int":
                    {
                        int a = int.Parse(Console.ReadLine());
                        int b = int.Parse(Console.ReadLine());
                        Console.WriteLine(GetMax(a, b));
                        break;
                    }
            }
        }

19 View Source File : DiagramBuilder.cs
License : MIT License
Project Creator : microsoft

private void BuildDiagram(string[] enreplacedies, string pagereplacedle)
        {
            // Get the default page of our new doreplacedent
            VisioApi.Page page = _doreplacedent.Pages[1];
            page.Name = pagereplacedle;

            // Get the metadata for each preplaceded-in enreplacedy, draw it, and draw its relationships.
            foreach (string enreplacedyName in enreplacedies)
            {
                Console.Write("Processing enreplacedy: {0} ", enreplacedyName);

                EnreplacedyMetadata enreplacedy = GetEnreplacedyMetadata(enreplacedyName);

                // Create a Visio rectangle shape.
                VisioApi.Shape rect;

                try
                {
                    // There is no "Get Try", so we have to rely on an exception to tell us it does not exists
                    // We have to skip some enreplacedies because they may have already been added by relationships of another enreplacedy
                    rect = page.Shapes.get_ItemU(enreplacedy.SchemaName);
                }
                catch (System.Runtime.InteropServices.COMException)
                {
                    rect = DrawEnreplacedyRectangle(page, enreplacedy.SchemaName, enreplacedy.OwnershipType.Value);
                    Console.Write('.'); // Show progress
                }

                // Draw all relationships TO this enreplacedy.
                DrawRelationships(enreplacedy, rect, enreplacedy.ManyToManyRelationships, false);
                Console.Write('.'); // Show progress
                DrawRelationships(enreplacedy, rect, enreplacedy.ManyToOneRelationships, false);

                // Draw all relationshipos FROM this enreplacedy
                DrawRelationships(enreplacedy, rect, enreplacedy.OneToManyRelationships, true);
                Console.WriteLine('.'); // Show progress
            }

            // Arrange the shapes to fit the page.
            page.Layout();
            page.ResizeToFitContents();
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : MoshiMoshi0

public MenuOption Show()
            {
                Service = ServiceController.GetServices()
                    .FirstOrDefault(s => s.ServiceName.Equals(TTInstaller.ServiceName));

                if (_header != null)
                {
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine(_header);
                    Console.WriteLine("================================");
                }

                var index = 0;
                var optionMap = new Dictionary<char, MenuOption>();
                foreach (var option in _options)
                {
                    var key = option.KeyOverride ?? (char) (index++ + (index > 9 ? 'a' : '1'));
                    optionMap.Add(key, option);

                    Console.ForegroundColor = option.Enabled() ? ConsoleColor.Gray : ConsoleColor.DarkGray;
                    Console.WriteLine("[{0}] {1}", key, option.Description);
                }

                Console.WriteLine();

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write($"[{string.Join(", ", optionMap.Where(kv => kv.Value.Enabled()).Select(kv => kv.Key))}]: ");

                while (true)
                {
                    var c = Console.ReadKey(true).KeyChar;
                    if (optionMap.ContainsKey(c) && optionMap[c].Enabled())
                    {
                        Console.ResetColor();
                        Console.WriteLine(c);
                        return optionMap[c];
                    }
                }
            }

19 View Source File : Program.cs
License : MIT License
Project Creator : mystborn

static void Main(string[] args)
        {
            bool run = false;
            bool generateBcl = false;
            bool generateBuild = false;
            bool time = false;

            var options = new OptionSet()
            {
                { "r", v => run = v != null },
                { "bcl", v => generateBcl = v != null },
                { "build", v => generateBuild = v != null },
                { "t", v => time = v != null }
            };

            var path = Directory.GetCurrentDirectory();
            var extra = options.Parse(args);
            if (extra.Count != 0)
                path = extra[0];

#if DEBUG
            path = @"C:\Users\Chris\Source\TaffyScript\WhereIsEveryone";
#endif

            if (generateBuild)
            {
                var build = new BuildConfig();
                build.References.Add("TaffyScript.BCL.dll");
                build.Save(path);
                return;
            }

            Console.WriteLine("Compile Start...");
            Stopwatch sw = null;
            if (time)
            {
                sw = new Stopwatch();
                sw.Start();
            }

            var logger = new ErrorLogger();

            var compiler = new MsilWeakCompiler(logger);
            CompilerResult result;

            if (!generateBcl)
            {
                result = compiler.CompileProject(path);
            }
            else
                result = compiler.CompileCode(BaseClreplacedLibraryGenerator.Generate(), new BuildConfig() { Mode = CompileMode.Release, Output = Path.Combine(Path.GetDirectoryName(typeof(Program).replacedembly.Location), "Libraries", "TaffyScript.BCL") });

            if (result.Errors.Count == 0)
            {
                if(result.Warnings.Count > 0)
                {
                    Console.WriteLine("Warnings:\n");
                    foreach (var warning in result.Warnings)
                        Console.WriteLine(warning);
                    Console.WriteLine('\n');
                }

                Console.WriteLine("Compile succeeded...");
                if(time)
                {
                    sw.Stop();
                    Console.WriteLine($"Compile time: {sw.ElapsedMilliseconds} ms");
                }
                Console.WriteLine($"Output: {result.PathToreplacedembly}");
                if (run && result.PathToreplacedembly.EndsWith(".exe"))
                {
                    Console.WriteLine("Running...\n");
                    RunOutput(result.PathToreplacedembly);
                }
            }
            else
            {
                Console.WriteLine("Compile failed...");
                Console.WriteLine("Errors: \n");
                foreach (var error in result.Errors)
                    Console.WriteLine(error);
            }
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : PacktPublishing

static void Main(string[] args)
      {
         // raw data
         {
            var path = @"C:\Temp\data.raw";
            var data = new byte[] { 0xBA, 0xAD, 0xF0, 0x0D};
            using(FileStream wr = File.Create(path))
            {
               wr.Write(data, 0, data.Length);
            }
            
            using(FileStream rd = File.OpenRead(path))
            {
               var buffer = new byte[rd.Length];
               rd.Read(buffer, 0, buffer.Length);

               Console.WriteLine(string.Join(" ", buffer.Select(e => $"{e:X02}")));
            }
         }

         // binary data
         {
            var path = @"C:\Temp\data.bin";
            using (var wr = new BinaryWriter(File.Create(path)))
            {
               wr.Write(true);
               wr.Write('x');
               wr.Write(42);
               wr.Write(19.99);
               wr.Write(49.99M);
               wr.Write("text");
            }

            using(var rd = new BinaryReader(File.OpenRead(path)))
            {
               Console.WriteLine(rd.ReadBoolean());  // True
               Console.WriteLine(rd.ReadChar());     // x
               Console.WriteLine(rd.ReadInt32());    // 42
               Console.WriteLine(rd.ReadDouble());   // 19.99
               Console.WriteLine(rd.ReadDecimal());  // 49.99
               Console.WriteLine(rd.ReadString());   // text
            }
         }

         // text data
         {
            var path = @"C:\Temp\data.txt";
            using(StreamWriter wr = File.CreateText(path))
            {
               wr.WriteLine("1st line");
               wr.WriteLine("2nd line");
            }

            using(StreamReader rd = File.OpenText(path))
            {
               while(!rd.EndOfStream)
                  Console.WriteLine(rd.ReadLine());
            }

            using(var rd = new StreamReader(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)))
            {
               while (!rd.EndOfStream)
                  Console.WriteLine(rd.ReadLine());
            }
         }

         // XML serialization
         {
            var employee = new Employee
            {
               EmployeeId = 42,
               FirstName = "John",
               LastName = "Doe"
            };
            
            var text = Serializer<Employee>.Serialize(employee);
            var result = Serializer<Employee>.Deserialize(text);

            Console.WriteLine(employee);
            Console.WriteLine(text);
            Console.WriteLine(result);
         }

         // data compression
         {
            var text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
            var data = Encoding.UTF8.GetBytes(text);
            var compressed = Compression.Compress(data);
            var decompressed = Compression.Decompress(compressed);
            var result = Encoding.UTF8.GetString(decompressed);

            Console.WriteLine($"Text size:    {text.Length}");
            Console.WriteLine($"Compressed:   {compressed.Length}");
            Console.WriteLine($"Decompressed: {decompressed.Length}");
            Console.WriteLine(result);
            if (text == result)
               Console.WriteLine("Decompression successful!");
         }
      }

19 View Source File : HttpClientSamples.cs
License : MIT License
Project Creator : ProfessionalCSharp

public async Task SimpleGetRequestAsync()
    {
        HttpResponseMessage response = await _httpClient.GetAsync("/");
        if (response.IsSuccessStatusCode)
        {
            Console.WriteLine($"Response Status Code: {(int)response.StatusCode} {response.ReasonPhrase}");
            string responseBodyAsText = await (response.Content?.ReadreplacedtringAsync() ?? Task.FromResult(string.Empty));
            Console.WriteLine($"Received payload of {responseBodyAsText.Length} characters");
            Console.WriteLine();
            Console.WriteLine(responseBodyAsText[..50]);
        }
    }

19 View Source File : HttpClientSamples.cs
License : MIT License
Project Creator : ProfessionalCSharp

public async Task ThrowExceptionAsync()
    {
        try
        {
            HttpResponseMessage response = await _httpClient.GetAsync(_invalidUrl);
            response.EnsureSuccessStatusCode();

            Console.WriteLine($"Response Status Code: {(int)response.StatusCode} {response.ReasonPhrase}");
            string responseBodyAsText = await (response.Content?.ReadreplacedtringAsync() ?? Task.FromResult(string.Empty));
            Console.WriteLine($"Received payload of {responseBodyAsText.Length} characters");
            Console.WriteLine();
            Console.WriteLine(responseBodyAsText[..50]);
        }
        catch (HttpRequestException ex)
        {
            _logger.LogError(ex, ex.Message);
        }
    }

19 View Source File : Program.cs
License : MIT License
Project Creator : ProfessionalCSharp

private static void RangeAndIndexwithStringArray()
        {
            string[] names = { "James", "Niki", "Jochen", "Juan", "Michael", "Sebastian", "Nino", "Lewis" };

            string lewis = names[^1]; // uses an index
            Console.WriteLine(lewis);
            foreach (var name in names[2..^2]) // uses a range
            {
                Console.WriteLine(name);
            }
        }

19 View Source File : GifPlayer.cs
License : GNU General Public License v3.0
Project Creator : ProjectStarlight

public void LoadFromPath(string path)
        {
            var stream = File.OpenRead(path);

            //Header

            for (int k = 0; k < 6; k++)
            {
                byte first = (byte)stream.ReadByte();
                Console.WriteLine(Convert.ToChar(first));
            }

            //Screen data

            int screenWidth = BitConverter.ToInt16(ReadBytes(2, stream), 0);
            Console.WriteLine(screenWidth);

            int screenHeight = BitConverter.ToInt16(ReadBytes(2, stream), 0);
            Console.WriteLine(screenHeight);

            byte formatData = (byte)stream.ReadByte();
            bool colorMapPresent = (formatData & 1) == 0;
            int colorResolutionBits = 1 + ((formatData >> 1));
            int pixelBits = 1 + (formatData & 0b111);


            int backgroundColorIndex = stream.ReadByte();

            _ = stream.ReadByte();

            //Color map
            Color[] colorMap = new Color[0];

            if (colorMapPresent)
            {
                int entries = (int)Math.Pow(2, pixelBits);
                colorMap = new Color[entries];

                for (int k = 0; k < entries; k++)
                {
                    colorMap[k] = new Color(stream.ReadByte(), stream.ReadByte(), stream.ReadByte());
                }
            }

            Color[] nextTextureData = new Color[screenWidth * screenHeight];
            string output = "";

            for (; ; )
            {
                var nextByte = stream.ReadByte();
                output += nextByte.ToString("x") + ", ";

                if (nextByte == ';')
                {
                    Main.NewText(output);
                    break; //GIF terminator. stop reading.
                }

                if (nextByte == ',')
                {
                    var image = ParseImageDescriptor(stream);

                    if (!image.useGlobalMap) //Image has a local map which should be used for colors
                    {
                        int entries = (int)Math.Pow(2, image.bitsPerPixel);
                        Color[] localMap = new Color[entries];

                        for (int k = 0; k < entries; k++)
                        {
                            localMap[k] = new Color(stream.ReadByte(), stream.ReadByte(), stream.ReadByte());
                        }
                        image.localMap = localMap;
                    }
                    else image.localMap = colorMap; //colorMap should be defined if any images dont use local maps.

                    //if (image.left == 0 && image.top == 0) //next image is top-left again, time to save a texture for the frame and reset!
                    //{
                        var tex = new Texture2D(Main.graphics.GraphicsDevice, screenWidth, screenHeight);
                        tex.SetData(nextTextureData);

                        textureData.Add(tex);

                        nextTextureData = new Color[screenWidth * screenHeight];
                    //}

                    if (!image.orderFormat) //sequential format
                    {
                        int codeSize = stream.ReadByte();
                        List<byte> rasterOutput = new List<byte>();

                        for (; ; )
                        {
                            int byteCount = stream.ReadByte();

                            if (byteCount == 0) 
                                break;

                            BitArray bits = new BitArray(byteCount * 8);

                            for (int k = 0; k < byteCount; k++)
                            {
                                var nextSet = new BitArray(new byte[] { (byte)stream.ReadByte() } );

                                for(int i = 0; i < 8; i++)
                                {
                                    int index = k * 8 + i;
                                    bits[index] = nextSet[i];
                                }
                            }

                            List<byte[]> LZWTable = new List<byte[]>();

                            for (int k = 0; k < 256; k++)
                            {
                                LZWTable.Add(new byte[] { (byte)k });
                            }

                            byte[] w = new byte[0];

                            for (int k = 0; k < bits.Length / codeSize; k++)
                            {
                                var keyBits = new BitArray(codeSize);

                                for (int i = 0; i < codeSize; i++)
                                {
                                    keyBits[i] = bits[k * codeSize + i];
                                }

                                var a = new int[1];
                                keyBits.CopyTo(a, 0);
                                int key = a[0];

                                byte[] entry;

                                if(key == Math.Pow(2, codeSize))
                                {
                                    LZWTable = new List<byte[]>();

                                    for (int i = 0; i < 256; i++)
                                    {
                                        LZWTable.Add(new byte[] { (byte)k });
                                    }

                                    continue;
                                }

                                if (LZWTable.Count >= key)
                                    entry = LZWTable[key];
                                else
                                {
                                    var synthesized = new byte[w.Length + 1];
                                    w.CopyTo(synthesized, 0);
                                    synthesized[w.Length] = w[0];
                                    entry = synthesized;
                                }

                                rasterOutput.AddRange(entry);

                                if (w.Length > 0)
                                {
                                    var newEntry = new byte[w.Length + 1];
                                    w.CopyTo(newEntry, 0);
                                    newEntry[w.Length] = entry[0];
                                    LZWTable.Add(newEntry);
                                }

                                w = entry;
                            }
                        }

                        for (int k = 0; k < rasterOutput.Count; k++)
                        {
                            nextTextureData[k] = image.localMap[rasterOutput[k]];
                        }
                    }
                    /*else //Interlaced format
                    {
                        var entries = image.width * image.height;
                        Color[] deInterlaced = new Color[image.width * image.height];

                        for (int k = 0; k < entries / 8; k++)
                        {
                            var targetIndex = k * 8;
                            deInterlaced[targetIndex] = image.localMap[stream.ReadByte()];
                        }

                        for (int k = 0; k < entries / 8; k++)
                        {
                            var targetIndex = 4 + k * 8;
                            deInterlaced[targetIndex] = image.localMap[stream.ReadByte()];
                        }

                        for (int k = 1; k < entries / 4; k++)
                        {
                            var targetIndex = k * 4 - 2;
                            deInterlaced[targetIndex] = image.localMap[stream.ReadByte()];
                        }

                        for (int k = 0; k < entries / 2; k++)
                        {
                            var targetIndex = 1 + k * 2;
                            deInterlaced[targetIndex] = image.localMap[stream.ReadByte()];
                        }

                        int index = 0;
                        for (int x = 0; x < image.width; x++)
                            for (int y = 0; y < image.height; y++)
                            {
                                index++;
                                nextTextureData[image.left + x + (screenWidth * (image.top + y))] = deInterlaced[index];
                            }
                    }*/
                }
            }
        }

19 View Source File : SimpleTextEditor.cs
License : MIT License
Project Creator : RAstardzhiev

public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var text = new StringBuilder();
            var history = new Stack<string>();

            for (int i = 0; i < n; i++)
            {
                var input = Console.ReadLine()
                    .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                var command = int.Parse(input[0]);

                switch (command)
                {
                    case 1: // 1 someString - appends someString to the end of the text
                        if (input.Length > 1)
                        {
                            history.Push(text.ToString());
                            text.Append(input[1]);
                        }

                        break;
                    case 2: // 2 count - erases the last count elements from the text
                        if (input.Length > 1)
                        {
                            var count = int.Parse(input[1]);
                            history.Push(text.ToString());

                            if (count > text.Length)
                            {
                                text.Clear();
                                break;
                            }

                            text.Remove(text.Length - count, count);
                        }

                        break;
                    case 3: // 3 index - returns the element at position index from the text
                        if (input.Length > 1)
                        {
                            var index = int.Parse(input[1]);

                            if (index <= text.Length && index > 0)
                            {
                                Console.WriteLine(text[index - 1]);
                            }
                        }

                        break;
                    case 4: // 4 - undoes the last not undone command of type 1 / 2 and returns the text to the state before that operation
                        text.Clear();
                        text.Append(history.Pop());
                        break;
                    default:
                        break;
                }
            }
        }

19 View Source File : OutputWriter.cs
License : MIT License
Project Creator : RAstardzhiev

public static void WriteLine(char ch)
        {
            Console.WriteLine(ch);
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : RAstardzhiev

static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Console.Write(new string(' ', n + 1));
            Console.WriteLine('|');

            for (int i = 1, s = n - 1; i <= n; i++, s--)
            {
                string space = new string(' ', s);
                String stars = new string('*', i);
                Console.WriteLine("{0}{1} | {1}", space, stars);
            }
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : RAstardzhiev

static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int RoofRows = (n + 1) / 2;
            string minusSpace = "";

            // Roof
            for (int i = 0, nStars = roofStarsFirstRow(n); i < RoofRows; i++, nStars += 2)
            {
                // Roof
                Console.Write(new string('-', (n - nStars) / 2));
                Console.Write(new string('*', nStars));
                Console.WriteLine(new string('-', (n - nStars) / 2));
            }
            // Base
            for (int i = 0; i < n / 2; i++)
            {
                Console.Write('|');
                Console.Write(new string('*', n - 2));
                Console.WriteLine('|');
            }
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : RAstardzhiev

static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Console.WriteLine(new string('*', n * 2) + new string(' ', n) + new string('*', n * 2));

            for (int i = 0; i < n - 2; i++)
            {
                // Left Side
                Console.Write('*');
                Console.Write(new string('/', 2 * n - 2));
                Console.Write('*');
                // Bridge
                if (i == (n - 1) / 2 - 1)
                    Console.Write(new string('|', n));
                else
                {
                    Console.Write(new string(' ', n));
                }
                // Right Side
                Console.Write('*');
                Console.Write(new string('/', 2 * n - 2));
                Console.WriteLine('*');
            }

            Console.WriteLine(new string('*', n * 2) + new string(' ', n) + new string('*', n * 2));
        }

19 View Source File : DrawFilledSquare.cs
License : MIT License
Project Creator : RAstardzhiev

public static void DrowSquare(int rows)
        {
            PrintLine(rows * 2);
            for (int j = 0; j < rows - 2; j++)
            {
                Console.Write('-');
                for (int i = 0; i < rows - 1; i++)
                {
                    Console.Write("\\/");
                }

                Console.WriteLine('-');
            }

            PrintLine(rows * 2);
        }

19 View Source File : GreaterOfTwoValues.cs
License : MIT License
Project Creator : RAstardzhiev

private static void GreaterChar()
        {
            char c1 = Console.ReadLine()[0];
            char c2 = Console.ReadLine()[0];
            Console.WriteLine((c1 > c2) ? c1 : c2);
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : sedc-codecademy

static void Main(string[] args)
        {
            // Length
            // ToLower()
            // ToUpper()

            string groupFeedback = "C# is GREAT programming language!";

            int numberOfCharactersInTheString = groupFeedback.Length;

            Console.WriteLine([email protected]"The length of {groupFeedback} ""STRING"" is {groupFeedback.Length} characters");

            Console.WriteLine("All letters smaller: {0}", groupFeedback.ToLower());
            Console.WriteLine("All letter CAPITAL" + groupFeedback.ToUpper());

            // Trim()
            // TrimStart()
            // TrimEnd()
            // Cut EMPTY SPACES in the beggining or at the end of the string

            string gitUsername = "           miodragc      ";
            Console.WriteLine("Git username: " + gitUsername.Length); //25

            string gitUsernameTrimmed = gitUsername.Trim();
            Console.WriteLine($"Git username length with Trim() is: {gitUsernameTrimmed.Length}"); //8

            string gitUsernameTrimmedStart = gitUsername.TrimStart();
            string gitUsernameTrimmedEnd = gitUsername.TrimEnd();

            Console.WriteLine("Please enter your username and preplacedword:");

            // StartWith()
            // EndsWith()
            // IndexOf() - String method

            string academySubjects = "HTML, CSS, Java Script, C#";

            string html = "HTML ";

            bool htmlIsFirstSubject = academySubjects.StartsWith("HTML");
            bool htmlIsFirstSubjectWithSpace = academySubjects.StartsWith(html.Trim());
            bool cSharpIsCurrentSubject = academySubjects.EndsWith("C#");
            var indexOfJavaScript = academySubjects.IndexOf("Java Script");

            Console.WriteLine($"HTML: {htmlIsFirstSubject}, C#: {cSharpIsCurrentSubject}, Java Script with index {indexOfJavaScript}");

            // Substring()

            //Get all subjects from SEDC, except HTML
            string allsSubjectsExceptHTML = academySubjects.Substring(6);
            Console.WriteLine("All subjects from SEDC without the HTML are: " + allsSubjectsExceptHTML);

            string cssSubject = academySubjects.Substring(6, 3);
            Console.WriteLine("Only CSS is----" + cssSubject);

            // Action point - Miodrag to think about Word processor :)

            // Split() - FANTASTIC!!!!   
            // string[]

            string academySubjectsAgaing = "HTML, CSS, Java Script, C#";

            string[] subjects = academySubjectsAgaing.Split(", ");

            //subjects = ["HTML", "CSS", "Java Script", "C#"] - SPLIT!!

            // HTML
            // CSS
            // Java Script
            
            string join = "";
            foreach (var subject in subjects)
            {
                join += subject + ", ";
            }

            // ToCharArray() - LIKE * LIKE
            // char[]

            char[] characters = academySubjectsAgaing.ToCharArray();
            // characters = ['H', 'T', 'M', 'L', .....]


            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(characters[0]);

            foreach (var character in characters)
            {
                Console.WriteLine(character);
            }

            Console.ReadLine();
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : sedc-codecademy

static void Main(string[] args)
        {
            SayMyName();
            SayHello();

            DisplayFullName("Ivo", "Kostovski");
            RoleCheck("Irina");
            RoleCheck("Ivo");

            Console.WriteLine(ShowMessage());
            Console.WriteLine(GenerateNumbers());
            Console.WriteLine(Multiply(5, 10));

            Calculator();


            #region Strings Concatenation

            //Concatenating strings
            //World Health Organization - WHO

            string worldHealthOrg = "World Health Organization";
            string worldHealthAbr = "WHO";

            //Simple concatenation
            string worldHealtOrgCon = worldHealthOrg + "-" + worldHealthAbr;
            Console.WriteLine(worldHealtOrgCon);

            //Formating string - PLACEHOLDERS
            Console.WriteLine("{0} - {1}", worldHealthOrg, worldHealthAbr);

            string worldHealthreplacedle = String.Format("{0} - {1}", worldHealthOrg, worldHealthAbr);
            Console.WriteLine(worldHealthreplacedle);

            long mobile = 38970223332;
            string phoneNumber = String.Format("{0:(###) ## ###-###}", mobile);
            Console.WriteLine(phoneNumber);

            float price = 150.29f;
            string priceCurrency = String.Format("{0:C}", price);
            Console.WriteLine(priceCurrency);

            float part = 0.5f;
            string percent = String.Format("{0:P}", part);
            Console.WriteLine(percent);
            #endregion


            #region String Methods
            //ToLower() and ToUpper()
            string fullName = "Martin Panovski";

            string fullNameToLower = fullName.ToLower();
            string fullNameToUpper = fullName.ToUpper();

            Console.WriteLine("ToLower - {0} / ToUpper - {1}", fullNameToLower, fullNameToUpper);

            string sedc = "         Seavus Education and Development Center        ";
            Console.WriteLine(sedc.Trim());
            Console.WriteLine(sedc.TrimStart());
            Console.WriteLine(sedc.TrimEnd());


            //String Interpolation
            string sedcLong = "Seavus Education and Development Center";
            string sedcAbr = "SEDC";
            string resultString = $"I am learing web development at {sedcLong} - {sedcAbr}";
            Console.WriteLine(resultString);

            //Length
            string description = "Today was such a sunny and funny day!";
            Console.WriteLine(description.Length);

            foreach (char character in description)
            {
                Console.WriteLine(" " + character);
            }

            int indexOfCharacter = description.IndexOf("a");
            Console.WriteLine(indexOfCharacter);

            //Substring()
            string descriptionSubString = description.Substring(0, 4);
            string descSubStr = description.Substring(5);
            Console.WriteLine(descriptionSubString);
            Console.WriteLine(descSubStr);


            //Split()
            string replacedistantName = "Ivo Kostovski";
            string[] fullNameSplited = replacedistantName.Split("");
            foreach (string name in fullNameSplited)
            {
                Console.WriteLine(name);
            }

            string[] worldSplited = worldHealthreplacedle.Split("-");
            foreach (string item in worldSplited)
            {
                Console.WriteLine(item.Trim());
            }

            //ToCharArray()
            char[] fullNameChars = fullName.ToCharArray();
            foreach (char character in fullNameChars)
            {
                Console.WriteLine(character);
            }

            //Contains
            bool hasCharacterInFulName = fullName.Contains('i');
            if (hasCharacterInFulName)
            {
                Console.WriteLine(fullName);
            }
            #endregion



            #region DateTime and DateTime manipulation

            DateTime date = new DateTime();
            Console.WriteLine(date);

            DateTime today = DateTime.Now;
            Console.WriteLine(today);

            //Creating a custom DateTime - my birthday
            DateTime birthday = new DateTime(1993, 08, 27, 13, 5, 12);
            Console.WriteLine(birthday);

            //DateTime combinations and from String conversion
            string date1 = "05/10/2020";
            string date2 = "05.10.2020";
            string date3 = "05/10/2020 13:05:12";
            string date4 = "05-10-2020";
            string date5 = "may.10.2020";

            //Console.WriteLine("DateTime converted from string:");
            DateTime convertedDate1 = DateTime.Parse(date1);
            DateTime convertedDate2 = DateTime.Parse(date2);
            DateTime convertedDate3 = DateTime.Parse(date3);
            DateTime convertedDate4 = DateTime.Parse(date4);
            DateTime convertedDate5 = DateTime.Parse(date5);

            Console.WriteLine(convertedDate1);
            Console.WriteLine(convertedDate2);
            Console.WriteLine(convertedDate3);
            Console.WriteLine(convertedDate4);
            Console.WriteLine(convertedDate5);


            //Formating dates
            int day = today.Day;
            int month = today.Month;
            int year = today.Year;

            Console.WriteLine($"Day: {day} Month: {month} Year: {year}");

            DateTime currentDate = today.Date;
            Console.WriteLine(currentDate);

            Console.WriteLine("Tomorrow is " + currentDate.AddDays(1));
            Console.WriteLine("Yesterday was " + currentDate.AddDays(-1));

            string dateFormat = today.ToString("MM/dd/yyyy");
            Console.WriteLine(dateFormat);

            string dateFormat2 = today.ToString("dddd, dd MMMM yyyy");
            Console.WriteLine(dateFormat2);


            //First check the format
            var check = DateTime.Now;
            Console.WriteLine("Format is: " + check);



            #endregion

            Console.ReadLine();
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : sedc-codecademy

static void Main(string[] args)
		{
			// Concatanation
			// What we will have as a result in the variable: "Bob is cool!"
			string normalConcat1 = "Bob " + "is cool!";

			// 1st parameter: the string
			// Other paramters after the first are values that should be replacing the {0} {1} numbers
			// What we will have as a result in the variable: "Bob is cool! another thing!"
			string formatConcat1 = string.Format("Bob {0} {1}", "is cool!", " another thing!");
			string formatConcat2 = string.Format("This is a sentence: {0}", formatConcat1);
			Console.WriteLine(normalConcat1);
			Console.WriteLine(formatConcat1);
			Console.WriteLine(formatConcat2);

			// String interpolation
			// WE MUST HAVE $ BEFORE THE "" TO USE THIS
			string interpolationConcat1 = $"This is a sentence: {normalConcat1}"; // C# 6
			Console.WriteLine(interpolationConcat1);

			// ESCAPE CHARACTERS
			// 1. By using \ character
			// Check your c:\drive
			Console.WriteLine("Check your c:\\drive");
			// We will have "fair" elections
			Console.WriteLine("We will have \"fair\" elections");
			// the \n sign means: new line
			Console.WriteLine("the \\n sign means: new line");

			// 2. By using @ character
			// Check your c:\drive
			Console.WriteLine(@"Check your c:\drive");
			// We will have "fair" elections
			Console.WriteLine(@"We will have ""fair"" elections");
			// the \n sign means: new line
			Console.WriteLine(@"the \n \n sign means: new line");

			// STRING FORMATTING
			// Currency
			// 1. Declare the string variable
			// 2. Lets find out what is the code in the initialization
			// 3. Execute whatever is there ( the method Format )
			// 4. The method Format returns a string
			// 5. Put that string in the variable
			string currencyFormating = string.Format("Bank account: {0:C}", 125.50);
			Console.WriteLine(currencyFormating);
			// Percentages
			string percentageFormating = string.Format("Battery: {0:P}", 0.5);
			Console.WriteLine(percentageFormating);
			// Custom formating
			string customFormating = string.Format("Phone: {0:(###) ##-###-###}", 38970555444);
			Console.WriteLine(customFormating);


			// Sring methods
			string ourString = "    We are learning C# and it is FUN and EASY. Okay maybe just FUN.     ";
			
			// Convert to lower case - Method ( does some action )
			string lowerCase = ourString.ToLower();
			string upperCase = ourString.ToUpper();
			Console.WriteLine(lowerCase);
			Console.WriteLine(upperCase);

			// Length - A property ( just keeps a value )
			int lengthOfString = ourString.Length;
			Console.WriteLine(lengthOfString);

			// Trim - Cuts the empty spaces from the front and back of the string
			string trimmedString = ourString.Trim();
			Console.WriteLine(trimmedString);

			// Split - Splits a string to an array of strings by a character or string
			string[] splittedString = ourString.Split(".");
			Console.WriteLine(splittedString[0]);
			Console.WriteLine(splittedString[1]);

			// starts with uppercase
			// StartsWith - We provide a string and it returns true or false depending on if that string really stars with that provided string
			bool doesItStartWith1 = ourString.StartsWith("Bob");
			bool doesItStartWith2 = ourString.StartsWith("    W");
			Console.WriteLine(doesItStartWith1);
			Console.WriteLine(doesItStartWith2);

			// IndexOf - It returns an integer ( the index ) of a staerting point of a string
			int indexOfString = ourString.IndexOf("C#");
			Console.WriteLine(indexOfString);

			// ToCharArray - converts a string in to an array of char ( array of characters )
			char[] ourStringCharacters = ourString.ToCharArray();
			Console.WriteLine(ourStringCharacters[7]);
			Console.WriteLine(ourStringCharacters[10]);
			Console.WriteLine(ourStringCharacters[12]);

			// Substring - Gets 2 int paramters ( index and length ) and cuts the string from the index to whicheer length
			string ourSubstring = ourString.Substring(5, 16);
			Console.WriteLine(ourSubstring);


			Console.ReadLine();
		}

19 View Source File : Program.cs
License : MIT License
Project Creator : Traeger-GmbH

public static void Main(string[] args)
        {
            //// If the server domain name does not match localhost just replace it
            //// e.g. with the IP address or name of the server machine.

            var client = new OpcClient("opc.tcp://localhost:4840/SampleServer");
            client.Connect();

            //
            // The data types used in following lines were generated using the OPC Watch.
            // https://docs.traeger.de/en/software/sdk/opc-ua/net/client.development.guide#generate-data-types
            //

            var job = client.ReadNode("ns=2;s=Machines/Machine_1/Job").As<MachineJob>();
            Console.WriteLine("Machine 1 - Job");
            PrintJob(job);

            var order = client.ReadNode("ns=2;s=Machines/Machine_2/Order").As<ManufacturingOrder>();

            Console.WriteLine();
            Console.WriteLine("Machine 2 - Order");
            Console.WriteLine(".Order = {0}", order.Order);
            Console.WriteLine(".Article = {0}", order.Article);

            Console.WriteLine();
            Console.WriteLine("Machine 2 - Order, Jobs");

            foreach (var orderJob in order.Jobs) {
                PrintJob(orderJob);
                Console.WriteLine('-');
            }

            client.Disconnect();
            Console.ReadKey(true);
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : Tuscann

static void Main()
    {
        char first = char.Parse(Console.ReadLine());
        char secound = char.Parse(Console.ReadLine());
        int counter = int.Parse(Console.ReadLine());
        
        int firstCountMoves = 0;
        int secoundCountMoves = 0;

        for (int i = 1; i <= counter; i++)
        {
            string curentCommand = Console.ReadLine();
            int lengt = curentCommand.Length;

            if (curentCommand == "UPGRADE")
            {
                first += (char)3;
                secound += (char)3;
            }
            if (i % 2 != 0)
            {
                firstCountMoves += lengt;
            }
            else if (i % 2 == 0)
            {
                secoundCountMoves += lengt;
            }

            if (secoundCountMoves >= 50 || firstCountMoves >= 50)
            {
                break;
            }
        }
        if (firstCountMoves >= secoundCountMoves)
        {
            Console.WriteLine(first);
        }
        else
        {
            Console.WriteLine(secound);
        }
    }

19 View Source File : Program.cs
License : MIT License
Project Creator : Tuscann

static void Main()
    {
        string type = Console.ReadLine();
        string first = Console.ReadLine();
        string secound = Console.ReadLine();

        if (type == "string")
        {
            string max = compareStrings(first, secound);
            Console.WriteLine(max);
        }
        else if (type == "int")
        {
            int max = compareInt(first, secound);
            Console.WriteLine(max);
        }
        else if (type == "char")
        {
            char max = compareChars(first, secound);
            Console.WriteLine(max);
        }
    }

19 View Source File : Program.cs
License : MIT License
Project Creator : Tuscann

static void Main()
    {

        string[] tickests = Console.ReadLine().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

        foreach (string ticket in tickests)
        {
            if (ticket.Length == 20)
            {
                char[] x = ticket.ToCharArray();

                var list = new Dictionary<char, List<int>>();

                for (int i = 0; i < x.Length / 2; i++)
                {
                    if (x[i] == x[i + 1])
                    {
                        Console.WriteLine(x[i]);
                    }
                }



            }
            else
            {
                Console.WriteLine("invalid ticket");
            }


        }

    }

19 View Source File : Program.cs
License : MIT License
Project Creator : Tuscann

static void Main()
    {
        string[] input = Console.ReadLine().Split('|').ToArray();

        for (int i = 0; i < input.Length; i++)
        {
            var curinet = input[i].ToCharArray();
            int sum = 0;
            int secoundsum = 0;
            int zerous = 0;
            int ones = 0;
            char last = 'a';

            for (int j = 0; j < curinet.Length; j++)
            {
                if (curinet[j] == '0')
                {
                    zerous++;
                }
                if (curinet[j] == '1')
                {
                    ones++;
                }
                if (j == 0)
                {
                    last = curinet[j];
                    continue;
                   
                }
                else
                {
                    if (last == '0' && curinet[j] == '0')
                    {
                        secoundsum++;
                    }
                    if (last == '1' && curinet[j] == '1')
                    {
                        secoundsum++;
                    }
                    last = curinet[j];
                    
                }
            }
            sum = zerous * 3 + ones * 5;
      
            //Console.WriteLine((sum));
            //Console.WriteLine(secoundsum);
            Console.WriteLine((char)(sum + secoundsum));




        }


    }

19 View Source File : Program.cs
License : MIT License
Project Creator : Tuscann

static void GetMaxValue(char value1, char value2)
    {
        Console.WriteLine(value1 > value2 ?
            value1 :
            value2
        );
    }

19 View Source File : Program.cs
License : MIT License
Project Creator : Tuscann

static void Main() // 100/100
    {
        string type = Console.ReadLine();

        if (type == "int")
        {
            int num1 = int.Parse(Console.ReadLine());
            int num2 = int.Parse(Console.ReadLine());
            int greaterValue = GetGreater(num1, num2);
            Console.WriteLine(greaterValue);
        }
        else if (type == "char")
        {
            char ch1 = char.Parse(Console.ReadLine());
            char ch2 = char.Parse(Console.ReadLine());
            char greaterValue = GetGreater(ch1, ch2);
            Console.WriteLine(greaterValue);
        }
        else if (type == "string")
        {
            string str1 = Console.ReadLine();
            string str2 = Console.ReadLine();
            string greaterValue = GetGreater(str1, str2);
            Console.WriteLine(greaterValue);
        }
    }

19 View Source File : Program.cs
License : MIT License
Project Creator : Tuscann

static void FindNthDigit(string number, int index)
    {
        for (int i = 0; i < number.Length; i++)
        {
            if (number.Length - index == i)
            {
                Console.WriteLine(number[i]);
                break;
            }
        }
    }