2018/8/4
C # interview Series continued
What is the difference between "System.Array.Clone ()" and "System.Array.CopyTo ()"?
1. "CopyTo ()" Copies elements from one array to another.
2. "Clone ()" Creates a new array that contains all the elements of the source array.
32) Can I use a circular reference?
You cannot loop a reference. In this case, a circular reference causes the condition of the lock to form, causing the resource to be unavailable.
What are the common exceptions in C #?
1, NullReferenceException
2, ArgumentNullException
3, DivideByZeroException
4, IndexOutOfRangeException
5, InvalidOperationException
6, StackOverflowException
34) What is a generic type?
Generics allow flexible creation of types that handle one or more types of states. The following advantages: code reuse, source code protection, type safety, clearer code, better performance.
35) What is an object pool?
Object pooling is used to track objects used in code, and object pooling can reduce the cost of creating objects. The same is also the presence of string pools, thread pooling, database connection pooling, and so on.
36) What is a delegate?
Pass the function as an argument to the method. Delegates are type-safe, allowing multiple methods to be called sequentially, supporting the invocation of static methods and instance methods.
37) What are the delegate types?
1. Single Delegate Delegate
2, Entrust chain multicast Delegate
3, generic commissioned Generic Delegate
38) What are the three types of generic delegates?
1. Func the. NET Framework currently provides 17
2. Action current The. NET Framework provides 17
3, predicate
Extra: In fact, only in MSCorLib.dll, there are nearly 50 delegate types
What is the difference between events and elegates?
An event is a special kind of delegate. The main difference is that the event provides an encapsulation of the agent.
40) Can I use delegates to make asynchronous calls?
OK.
What are the delegates represented in C #?
1. Callback mechanism Callback mechanism
2, asynchronous processing asynchronous processing
3. Abstraction and encapsulation methods abstract and encapsulate method
4. Multicast multicasting
42) What is a nullable type?You can represent a value type as null. The < value type variable is never null, and it always contains the value of the value type itself > For example, when a database field is mapped to a C # type, the database field can be allowed to be empty. Extra: int? Value=null;
43) What is an empty join operator < Nullable coalescing operator> "??"?“??” Operator gets two operands. Assuming that the coordinate operand is not empty, the operand is returned, or the right operand is returned.
What is the difference between the "as" and "is" operators?
1, "as" to verify compatibility with a certain type, compatibility returns a non-null reference to the same object, otherwise null is returned.
2, "is" to check whether the object type is compatible with the specified type. No exception is thrown.
C # code is managed or unmanaged code?
C # code is managed code. The compiler compiles the code into an intermediate language.
The role of the "lock" syntax?
"Lock" ensures that a resource is exclusive between threads, which causes the thread to wait and know that the resource is freed. Often used for multithreaded programming, sharing resources or exclusive resources can reduce application efficiency.
47) What is Hashtable?
Used for key-value pair storage, the key is unique. Use keys to access elements in the collection. It's used to store the Key/value pairs based on hash code of the key. Key'll be used to access the element in the collection. For example,
48) What is an enumeration?
The "enum" keyword is used to declare an enumeration, which has a constant composition and is called by an enumerator. Enumerations are value types and cannot be inherited.
What is the difference between "continue" and "break"?
1. "Continue" is used to skip the current loop and go to the next loop.
2. "Break" is used to jump out of the loop body.
50) What are boxing and unboxing?
1, "Boxing" converts a value type to a reference type.
2, "unboxing" converts the reference type to a value type.
Extra: The process of packing and unpacking will cause performance loss.
51) What is the partial class <partial class>?
Some classes allow code files of the same class to be scattered across multiple files. Use the "partial" keyword.
52) What is the anonymous type <anonymous type>?New features added by C # 3.0. Allows you to create objects at compile time. Extra: In fact, the compiler helped us to create some work, which belongs to a specific form of syntactic sugar.(
) C # compiler name is?
Csc
What are the collection types in C #?
1, ArrayList
2. Stack
3. Queue
4, SortedList
5, HashTable
6, Bit Array
55) What is a thread?
A process is a single execution of a program, a process that contains one or more threads, and a thread is the basic unit of dispatch and resource allocation. A thread has three states, blocking, running, and ready.
56) Enumerate the attributes and methods of the thread class?
CurrentCulture, CurrentThread, CurrentContext, IsAlive, Isthreadpoolthread, IsBackground, priority
What are Access Modifiers?
1, public any place can access
2. Private class can access
3. Protected classes and subclasses can access
4. Internal the current project set can be accessed
5. Protected internal classes and subclasses under current project set
58) What is Data encapsulation <data encapsulation>?
The process of hiding important fields for the end client.
C # Can i inherit more?
A class can inherit only one parent class and inherit multiple interfaces.
60) What is polymorphic <polymorphism>?
The ability of a programming language to handle objects differently according to different data types is called polymorphism. For example: Compile-time polymorphic reload <Overloading>; run-time polymorphic override <Overriding>.
So far I dare not to c#,c# that some advanced features of mastery are not specifically understood. Go on...
C # face questions and Answers 31-60