您的位置:首页 > 其它

概念记录 - 学习时遇到的概念和知识的简单记录

2009-10-13 12:38 232 查看
.NET Related:
***************************
Interface
Abstract Class
Component

Serialization
Binary
SOAP - A bit slower than Binary method
XML - Can't serialize non-public members. Can be used on cross-platform situation
Deserialization

Reflection
ConstructorInfo
?How to load a type at runtime into assembly?
Answer:

Event

  Declared in a class, which has

public delegate void <custom>EventHandler(object Sender, EventArgs e) to indicate signature of event handler;
a field-like event (i.e Changed);
Invoking the event(i.e a protected virtual On<custom>Changed(EventArgs e)) Changed(sender, e) at certain place;

Delegate

From MSDN:

Delegates are useful when:

A single method is being called.
A class may want to have multiple implementations of the method specification.
It is desirable to allow using a static method to implement the specification.
An event-like design pattern is desired.
The caller has no need to know or obtain the object that the method is defined on.
The provider of the implementation wants to "hand out" the implementation of the specification to only a few select components.
Easy composition is desired.

Interfaces are useful when:

The specification defines a set of related methods that will be called.
A class typically implements the specification only once.
The caller of the interface wants to cast to or from the interface type to obtain other interfaces or classes

Abstract class and memebers


You are not required to declare a method as virtual. But, if you don't, and you derive from the class, and your derived class has a method by the same name and signature, you'll get a warning that you are hiding a parent's method. You will have to use the 'new' keyword to remove the warning.

This functionality is there to help deal with compatibility issues between versions of classes.


Virtual class and members

  Virtual basically tells the compiler that the V-Table entry can be overwritten by children.

Difference between Interface and Abstract Class

An Interface cannot implement methods.
An abstract class can implement methods.

An Interface can only inherit from another Interface.
An abstract class can inherit from a class and one or more interfaces.

An Interface cannot contain fields.
An abstract class can contain fields.

An Interface can contain property definitions.
An abstract class can implement a property.

An Interface cannot contain constructors or destructors.
An abstract class can contain constructors or destructors.

An Interface can be inherited from by structures.
An abstract class cannot be inherited from by structures.

An Interface can support multiple inheritance.
An abstract class cannot support multiple inheritance.

simple type aliases a struct type

What's the 'new' 'override' keyword?

  Using new

    Methods from derived class and base class are separated. Method in derived class behaves like a completely new one. It doesn't implement base class methods(containing same name abstract methods will cause compling error).

  Using override

    When calling method through a base class pointer to derived class object, override method will find the method in derived class instead of calling method in base class

Thread Safety

Session

AppDomain

Try Catch meaning

  Catch will 'catch' Exception, stop excuting current calling and return to former calling point. Otherwise a Unhandled Exception will show up stopping application(hang).
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐