(C#)基本概念一览表-创新互联
abstract class
10年的盱眙网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网整合营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整盱眙建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。成都创新互联公司从事“盱眙网站设计”,“盱眙网站推广”以来,每个客户项目都认真落实执行。An abstract class is a class that must be inherited and have the methods overridden. It can not be instantiated. And at least one of the methods in the class is abstract.
Array, ArrayList, BitArray
An array is a collection of related instance either value or reference type. Array proceses an immutable structure in which the number of dimensions and size of the array are fixed at instantiation.
ArrayList is a dynamic array. Elements can be added & removed from an ArrayList at the runtime.
Array.CopyTo(), Array.Clone()
CopyTo() method copies the elements into another existing array.
Clone() method returns a new array boject containning all the elements in the original array.
Both are shallow copy.
For value type, it is no differece, a bit by bit copy of the fileds is performed, in stack.
For reference type:
Shallow copy:-> the reference is copied but the referred object is not, therefore the original object and its clone refer to the same object.
Deep copy: Both the reference and the referred object are copied.
as, is
"as" operator is used for casting of objects to a type or a class.
"is" operator is used to check the compatibility of an object with a given type and it returns the result as bool.
attribute
C# provides developers a way to define declarative tags on certain entities e.g. Class, method etc. are called attributes. The attribute's information can be retrieved at runtime using Reflection.
B
Boxing & Unboxing
Boxing: Implicit conversion of a value type (int, char etc.) to a reference type (object), is known as Boxing. In boxing process, a value type is being allocated on the heap rather than the stack.
Unboxing:
Explicit conversion of same reference type (which is being created by boxing process); back to a value type is known as unboxing. In unboxing process, boxed value type is unboxed from the heap and assigned to a value type which is being allocated on the stack.
C
Class & Struct
1. Structs are value types, while Classes are reference types.
2. Structs cannot inherit.
Const & Readonly
Const is declared and initialized at complile time. The value cannot be changed after wards.
Readonly variables will be initialized only from the static constructor of the class. Readonly is used when we want to assign the value at run-time.
Compare
Value type: Using == or != operator.
Reference type: Other override "bool Equails(object obj)" method Or implement Icomparable interface
But string type is different. The compiler automatically compares the values instead of references when == or != operators are used on string types. If want to compare reference only, it can be done as follows: If ((object)str1 == (object)str2) {};
D
delegate
A delegate object encapsulates a referecne to a method. Like a function point in C++.
multicast delegate
Multicasting is the ability to create an invocation list, or chain of methods that will be automatically called when a delegate is invoked. Such a chain is easy to create by using "+=" operator to add methods to the chain. To remove a method, use "-=". Multicasting should always retur a void type because the value retruned by the last method because the return value of the entire delegate invocation.
Debug & Trace
Using Debug class for debug builds, use Trace class for both debug and release builds.
Dispose & Finalize
Dispose is used to free un-managed resource like files, database connects etc, Finalize can be used to free un-managed resources in the destructor.
Dispose is explicitly called by user code and the class which is implementing dispose method. Finalize is called by GC and cannot be called by user code.
There is performance costs associated with Finalize method since it doesn't clean the memory immediately by GC
H
HashTable
A hashtable is a collection of key-value pairs. It allows one wirtting thread and multi-threads of reading.
G
GAC(Global Assembly Cache)
The GAC is the Global Assembly Cache. Shared assemblies reside in the GAC; this allows applications to share assemblies instead of having the assembly distributed with each application. Versioning allows multiple assembly versions to exist in the GAC—applications can specify version numbers in the config file. The gacutil command line tool is used to manage the GAC.
It is located at %winroot%assembly (Assembly a1 = Assembly.Load(assemlyName);)
R
reflection
Reflection is the ability to find the information about types contained in an assembly at runtime.
ref & out
An argurment pased as ref must be initialized before passing to the method where as out parameter needs not to be intialized before passing to a method
S
Stack
This is a collection that abstrcts LIFO data structure in which initial capacity is 32.
static
static class: a static class can not be instantiated. We can access the members of a static calss by using the class name itself
static members: The static member is callable on a class even when no instance of the class has been created.
string
string is immutable, so each time a string is changed, a new instance in memory is created.
StringBuilder
StringBuilder is more efficent in cases where there is a large amount of string manipulation. It is mutable.
U
Unit test
Positive test cases ( correct input, correct output)
Negative test cases ( broken or missing data, wrong input, proper handling)
Excpetion test cases ( exceptions are thrown and caught properly).
Using
The using block is used to obtain a resource and use it and then automatically dipose of when the execution block completed.
本文名称:(C#)基本概念一览表-创新互联
文章源于:http://scyanting.com/article/dsjsjs.html