zoukankan      html  css  js  c++  java
  • C#复习中...

    CIL: Common Intermediate Language 公共中间语言
    CLR: Common Language Runtime 公共语言运行库
    Creation of New Types is the essence(核心)of OOP.
    Type(类型) is defined by class and object(对象) is the instance(实例) of class.
    赋值语句: 值域大的变量 = 值域小的变量;
    占位符
    foreach循环
    Three pillars(3大支柱) of OOP Encapsulation(封装) Polymorphism(多态) Inheritance(继承)
    declare optional arguments e.g int foo(int a double b=6.5){ ... }
    Constructor:No return type Declared as Public accept arguments
    Using Static Members: static
    You access a static member through the name of the class/object in which it is declared.
    The members of a class can be either instance members or static members.
    Static methods don’t have a this reference.
    Static method can not access a non-static member variable.
    ref and out(按引用传参)
    out 可以对未赋初值的参数进行赋值
    Overloading(重载) Methods & Constructors 使用同一个“方法名”提供不同功能。
    Overloading vs Overriding
    Overloading is when you have multiple methods in the same scope, with the same name but different signatures
    Overloading (Compile Time Polymorphism):: Functions with same name and different parameters
    Overriding is a principle that allows you to change the functionality of a method in a child class.
    Overriding (Run Time Polymorphism): Functions in the extended class with same name and same parameters as
    in the base class, but with different behaviors.
    ncapsulating(封装) Data with Properties(属性)
    Properties{get ; set ;}
    override :
    public class ListBox : Control { public new virtual void Sort() {...}
    Use new to indicate that it is not an override of the base method in Control class.
    public class ListBox : Control { public override void Sort() {...}
    Use override to indicate that it does want to override of the base method in Control class.
    e.g
    class A { public virtual void Movie() { Console.WriteLine("MikiMouse"); } }
    class B : A { public override void Movie () { Console.WriteLine("DisneyMovie"); } }
    class C : B { public new virtual void Movie () { Console.WriteLine("Snow White"); } }
    class D : C { public override void Movie () { Console.WriteLine("Seven Dwarfs "); } }
    class TestMe{ static void Main() {
    A objA = new D();
    A objB = new B();
    C objC = new D();
    A objD = new A();
    objA.Movie();
    objB.Movie ();
    objC.Movie ();
    objD.Movie(); } }
    Abstract Classes
    To require subclasses to implement a method of their base, you need to designate that method as abstract.
    Once you declare a method to be abstract, you prohibit the creation of any instances of that class.
    Sealed 类(完全不允许派生), 防止偶然继承。与Abstract类(用来派生)正相反。
    C# insists that the both of logical operator pairs should be overloaded. Otherwise , It generates a Compile Error.
    等于操作符(==)重载(overload)时,同时也应该覆盖 (Override) Object提供的虚方法Equals(),
    让它也采用重载的(==)进行操作。当然(!=)也要重载。
    关于类型转换,当我们将小范围值转换为大范围值或者是转换会使数的精度有损失的时候需要显式转换
    implicit 隐式 explicit 显式
    Interfaces vs Abstract Classes
    一个类/接口可以继承一个类 一个类/接口可以继承多个接口
    当继承自抽象类时,选择性的override函数,当继承自接口时,必须实现所有函数
    注意:接口中的所有函数只需要写签名,且不能用access-modifie
    as:Casts the left operand to the type specified by the right operand. Returns null if the cast fails.
    继承自接口的类可以将接口中的方法用虚函数的方法实现,再在子类中override该方法
    继承的多个接口有同名的方法时,应该标明实现的是哪个方法
    Arrays
    Sort():排序方法(默认升序)
    If you need control over how the sort ordering is defined, Creating a custom implementation of IComparer is necessary.
    One of the useful properties Length: tells how many objects in an array.
    Two useful static methods of Array are Sort() and Reverse().
    IEnumerable<T> Interface 想要使用foreach必须实现该接口
    Queue first-in,first-out (FIFO)
    Stack last-in,first-out(LIFO)
    Strings: immutable(不可变)的unicode字符序列
    ReferenceEquals()判断两个引用是否相同
    ToString() method
    Another common way to create a string is to call the ToString() method
    on an object and assign the result to astring variable.
    Compare(s1,s2)小于:返回负数 等于:返回0 大于:返回正数
    Substring(int startIndex, int length)startIndex,:起始位置 length:长度(可缺省) 返回子串
    Split( params char[] separator ) 按所给的分隔符将string分割为string数组
    The System.Text.StringBuilder class is used for creating and modifying strings.
    Unlike String, StringBuilder is mutable(可变的).
    Exceptions
    对于可预测但不可避免的问题使用exception 处理。
    try{ } catch(){ }
    一个try可接多个catch,一个异常只会被最先符合的catch语句处理一次
    当多个catch语句的异常有层次关系时,应该按从小到大的顺序catch(先处理派生最深的异常类型)
    finally 语句块,可以没有catch 语句块,但是必须有 try 语句块 。 无论异常是否发生,这里的代码都会被执行
    Event(事件) is when something happens. (user action/change of system result/message received from outside the system )
    A delegate(委托) is an object that contains the address of a method.
    将事件(event)与事件发生时要完成的动作或方法(action/method)关联起来(hook up),就需要使用委托(delegate)来完成。
    Two ideal useful ways of delegate Event handling Callbacks
    Lambda Expressions
    extends the concept of anonymous methods and introduces lambda expressions(=>),
    which are more powerful and flexible than anonymous methods.
    LINQ (Language-INtegrated Query)
    LINQ is a bridge over object-oriented languages and relational database.
    from ...
    where...
    select...
    LINQ的查询结果会随着数据源的改变动态改变
    [data source 1] join [data source 2] on [join condition] join 连接两个数据源
    orderby 升序 orderby descending 降序
    XML eXtensible Markup Language
    An element can have zero or more child elements, and (except for the root element)
    every element has exactly one parent element.
    Elements with the same parent element are called sibling(兄弟) elements.
    Every element must be closed. e.g., colsed tag <MiddleName />
    No elements may overlap., though they may neste.
    XML Allows users to define their own tags.
    System.Xml.Serialization namespace: serializing & deserializing objects. XML的序列化
    partial 关键字。 这意味着可以在其他源程序文件中为该类添加方法 。
    ADO.NET: Activex Data Object .NET
    SQL:Structured Query Language
    WPF(Windows Presentation Foundation)
    Extensible Application Markup Language (XAML)
    Attributes are program elements that decorate code to provide declarative functionality and metadata for a program.
    Threads are responsible for multitasking within a single application.
    Threads are typically created when you want a program to do two things at once.
    The simplest way to create a thread is to create a new instance of the Thread class.
    Thread myThread = new Thread( new ThreadStart(Incrementer) );
    join()在一个线程中启动另一个线程
    sleep()让线程停止一段时间
    start()启动线程
    Monitor
    Wait()
    Exit()
    Using the basic FileStream class to perform a binary read & write of a file.
    A BufferedStream object is composed around an existing Stream object that you already have created.
    If you know that the file you are reading (and writing) contains nothing but text,
    you might want to use the StreamReader and StreamWriter classes.

    补充:页面加载时,会触发OnNavigatedTo()

    导航到其他页面 Navigate ()

  • 相关阅读:
    [super dealloc]内存释放的先后顺序
    NSString的常用方法
    Xcode开发技巧之code snippets(代码片段)
    关于oc运行时 isa指针详解
    ios快捷键
    自动释放池的使用
    【字典树】统计难题
    数据结构实验之图论五:从起始点到目标点的最短步数(BFS)
    字典树模板
    数据结构实验之串三:KMP应用
  • 原文地址:https://www.cnblogs.com/ljc825/p/4531883.html
Copyright © 2011-2022 走看看