zoukankan      html  css  js  c++  java
  • week 6

    delegate

    i'm always struggling with new ideas,now i'd like to show you a piece of code:

    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace Delegate {


         public delegate void GreetingDelegate(string name);
            class Program {

               private static void EnglishGreeting(string name) {
                   Console.WriteLine("Morning, " + name);
               }

               private static void ChineseGreeting(string name) {
                   Console.WriteLine("早上好, " + name);
               }

               private static void GreetPeople(string name, GreetingDelegate MakeGreeting) {
                   MakeGreeting(name);
                }

               static void Main(string[] args) {
                   GreetPeople("Jimmy Zhang", EnglishGreeting);
                   GreetPeople("张", ChineseGreeting);
                   Console.ReadKey();
               }
            }
        }

    output:

    Morning, Jimmy Zhang
    早上好, 张

    regular expression
    extract pattern
    by using function:
    whether the string matches the regular expression
    substring
    modify and change a string automatically

    literals :character to match
    metacharacters :command

    namespace:System.Text.RegularExpressions
    \S non space
    \s space
    + one or more

    regex
    IP mail address time web site

    exception
    bug programmer's mistake
    error user action
    exception predictable but unpreventable problems try catch

    throw catch
    System.Exception
    can't be solved throw to its parent
    skip the code after
    catch block
    the first one is the most specified
    the last one is the most general one

    delegate event
    contain the address of method
    pointer of method
    use method when encounter the pointer
    delegate sample()
    public int method()
    sample.m =new sample(instance.method)

    lambda expression=>

    asynccallback
    main is running while the date hasnot ready

    await a method
    intelligently pack the rest of the method into asynccallback

    into a new thread

    when the data is ready it comes back and continue to execute

    async await

  • 相关阅读:
    洛谷P3178 [HAOI2015]树上操作 题解 树链剖分+线段树
    洛谷P2590 [ZJOI2008]树的统计 题解 树链剖分+线段树
    2017年NOIP普及组复赛题解
    洛谷P3957 跳房子 题解 二分答案/DP/RMQ
    2016年NOIP普及组复赛题解
    2015年NOIP普及组复赛题解
    2014年NOIP普及组复赛题解
    洛谷P2258 子矩阵 题解 状态压缩/枚举/动态规划
    2013年NOIP普及组复赛题解
    第四章 选择结构(二)
  • 原文地址:https://www.cnblogs.com/itria/p/4439971.html
Copyright © 2011-2022 走看看