Example #1
0
        //Method-
        //A method is a code block that contains a series of statements
        //Named blocks of code that perform task (the "verbs")
        //Methods are declared in a class or struct
        //Executed by calling the method and specifying any required method arguments
        //In C#, every executed instruction is performed in the context of a method

        //Must be a member of a class
        //The method signature must be unique
        //First letter of it name must be a letter or a underscore (proper casing- capitalize first letter)

        //Allows for code reusability
        //Organize complex problems - into small steps
        //Better code readability (meaningful names)

        //Creating a method we need 5 things:
        //1. Access level- who call the method
        //2. Return type- does it return data? if so what type
        //3. Name- alias, other pieces code call this
        //4. Parameters- data that is passed into a method to do its job
        //5. Code block- statements that run when method is called
        //1-4 make up the method signature

        //The Main method is the entry point for every C# application (called by CLR when program starts)

        static void Main(string[] args)
        {
            Example Ps = new Example();

            Ps.PrintSomething();
            //Instantiating the class 'Example' - declaring the variable type
            //name of new variable 'Ps'
            //creating a new object "instance", and assiging variable to it


            Console.WriteLine("Press 'Enter' to start stopwatch");
            Console.ReadKey();

            StopWatch sw = new StopWatch();

            sw.StartTime();

            Console.WriteLine("Press 'Enter' to stop stopwatch");
            Console.ReadKey();
            sw.StopTime();


            Calculator Cal = new Calculator();

            Console.WriteLine(Cal.Add(1, 2));

            Console.WriteLine(Cal.Sub(1, 2));

            Console.WriteLine(Cal.Muly(1, 2));

            Console.WriteLine(Cal.Div(1, 2));

            Console.WriteLine(Cal.FindMax(1, 2, 3));

            Console.WriteLine("Enter a number to be squared");
            string snumber = Console.ReadLine();
            int    number  = int.Parse(snumber);

            Console.WriteLine(Cal.Square(number));
        }
Example #2
0
        public static void Main(string[] args)
        {
            var myWatch = new StopWatch();

            myWatch.StartTime();
            //Thread Sleep is like SetTimeout for JavaScript
            Thread.Sleep(1000);
            myWatch.StopTime();

            var myPost = new Post("Virtue", "So Help me God");

            myPost.VoteUp();
            myPost.VoteUp();
            myPost.VoteUp();
            myPost.VoteDown();
            myPost.DisplayVotes();

            //var dbMigrator = new DbMigrator(new FileLogger("C:\\Documents\\CodingDojo\\Bootcamp\\C#\\OOP\\log.txt"));
            //Logs are stored at this path.
            //
            //dbMigrator.Migrate();

            WorkFlow WorkFlow = new WorkFlow();

            WorkFlow.Add(new VideoUploader());
            WorkFlow.Add(new CallWebService());
            WorkFlow.Add(new SendEmail());
            WorkFlow.Add(new ChangeStatus());

            var engine = new WorkFlowEngine();

            engine.Run(WorkFlow);

            List <object> tList = new List <object>();

            tList.Add("Javier");
        }