. NET Work Preparation--02 basics

Source: Internet
Author: User
Tags soap local time net thread string format asymmetric encryption

(OBSOLETE)

Framework basics, Syntax basics, Strings & collections & streams, common classes and interfaces;

02.net Foundation (emphasis)
-Part I framework Basics
1. Basic Concepts
CTS (Common Type System), CLS (Common Language Specification), CLR (Common languageruntime);
Environmental Foundation-.net Framework;
Assembly (Assembly), appdomain:[process

[CLR [AppDomain]]

2. Operating mechanism
*c#--csc.exe-->il--jit--> Machine code (Key understanding: Generating machine codes in the development environment (deployment-time cache)/production environment (JIT))
Concept supplement: JIT directives and JMP directives
Tool Ildasmde
[Pe/coff header [CLR header [middle code, resource data, static data pool, metadata table, assembly manifest]]
* Assembly Loading
Order: Application Directory---application version policy->codebase in application domain--.
A = Assembly.LoadFrom ()/load (strong naming); A.createinstance ();
* Configuration Version Policy: Application policy, publisher policy (for assemblies placed in GAC), computer policy;

3. Build, deploy, manage
* Strong Signature assembly: An assembly with a public key and a digital signature, including 4 elements: file name, version number, language culture, public key;
Note:. NET is also encrypted with an asymmetric secret key.
*GAC (Global Assembly Cache): c:\windows\assembly\, note that it must be a strong signed assembly with a public key;
* Delay Signature: The strong signature program's private key encryption and digital signature delay to the century release;

4. Famous Enterprise Exercises
* are programs written in C + + able to run on. Net? You can refer to Dll,import;
* What is managed code?. NET platform to help you manage memory release code, also known as garbage collection;
* What is the application domain and what is the difference between him and the process? The AppDomain is a logical unit in the CLR that provides code-running scopes, error isolation, and security settings isolation. One or more AppDomain runs in the OS process;
* Strong signature and weak signature difference? Strong signature contains public key, digital signature, can be put into GAC;
* How do I upgrade an assembly in the system individually? How to express.
* The concept and function of public key keys? Cryptography, asymmetric encryption algorithm, private key encryption, public key digital signature;
* What are the benefits of putting assemblies into the GAC? Easy to share, ensuring that the assembly can be found and loaded by the CLR;
What technology does *,net use to remove the difference between DLL hell?com and. NET,. NET uses metadata and logical types to solve this problem; Note: The answer is not very satisfactory;
* How to specify version at compile time? AssemblyInfo.cs in the app;
* Delay the role of signature to facilitate the development of testing;

-Part II Syntax basics
1. Basic types and syntax
System.Object method: Equals (), GetHashCode (), GetType () involves reflection, ToString (), ReferenceEquals (), MemberwiseClone (), Finalize ( );
* Difference between a value type and a reference type
System.object->system.valuetype (others are reference types): assignment is the difference, the difference between memory allocation, the difference of inheritance structure;
* Unboxing and avoid unboxing
Note InvalidCastException when unpacking;
Scenarios to avoid: value types formatted output (using such as ToString ()), System.Object types of containers (such as ArrayList, using generics);
* Substitution of global variables: public static variables;
The difference between *struct and class: Struct cannot inherit, cannot define no parameter construction method, auto initial is 0 and cannot set initial value at definition;
* The concept of a type initializer: a method with the same name as the type, a parameterless return value, and a static definition. cctor (), called with a 2 strategy, beforefieldinit (with high efficiency);
* Parameter passing: Ref,out;params, allows the method to define the number of parameters in the definition, note that the params is not allowed to have other parameters;
*string and string exactly the same, alias, as far as possible unified;
*.net supported access levels and the default access levels for different types of members:
Private Priavte
Family protected
Assembly Internal
Family&assembly not implemented
Assembly or Family protected internal
Public public
---------------------------------------
Enum Public
Class Private
Interface Public
Struct Private
* Attributes and similarities and differences between attributes and methods: Nature is the same, attributes are convenient to expand;
Deep copy and shallow copy in *c#: MemberwiseClone () is a shallow copy--Copy all non-static value type members from the original object and all reference type references; You can use the IClonable Interface Clone () method to achieve the replication you need, However, it is important to note that the type that can be inherited requires careful implementation of this interface;
Syntax for looping in *c#: While,do...while,for,foreach (advantages, robustness, inadequacy, cannot change member values);
*c#using and unmanaged resource deallocation: Any type with unmanaged resources is necessary to implement the IDisposable Dispose method, which provides a method for efficiently invoking the object Dispose ();
The corresponding are: try/catch/finally;

2. Memory Management and garbage collection
* Stack and heap similarities and differences: such as a 32-bit OS,4GB virtual memory space of the opening-stack, managed heap, unmanaged heap;
* How much memory is allocated for executing string abc= "AAA" + "BBB" + "CCC"? Interesting, compiler optimizations, relationships with string pools.
*.net in GC: The algorithm finds objects that are no longer used, moves objects so that the objects used are still used on one side of the managed heap, and adjusts each state variable; avoid using Gc.collect to perform garbage collection;
The Finalize () method is similar to the destructor, but the internal implementation mechanism of the CLR is quite complex, including the structure of the object table to be destructor, and the waiting for the destructor table.
Design template for Dispose () with Finalize (): note Dispose (true); Gc. SuppressFinalize (True)--notifies the. NET object to be recycled without invoking the Finalize method to improve performance;
Tip: The Dispose method is invoked by the user, and the Finalize method is called by a dedicated. NET thread after the object is reclaimed by the first round of garbage collection.
*GC Concept: The GC mechanism divides the objects in the managed heap into 3 generations according to the possibility that the object is not being used: 0 generations, 1 generations, 2 generations, the smaller generation gets more release opportunities, and each time the object instance that is still alive in the GC is moved to the next generation;
*GC how to tell if an object is still being used:
Distinguish between root references, non-root references; The GC uses the root reference to traverse all instances of the referenced object, and when an object cannot be traversed, it is considered to be no longer used, and when the root reference traversal arrives at an object that is already considered to be in use, it will end this branch traversal and avoid a dead loop;
*.net whether there is an internal pure leak in the memory managed heap: the allocation of large objects (String), improper preservation of the root reference, the wrong Finalize method;

3. Object-oriented implementation
There is a maximum of one parent class in *c#, but multiple interfaces can be implemented;
* Overrides, overloads, Hidden concepts:
Rewrite and hide: Define a base class and two subclasses, define a virtual method in the base class: GetString (), two subclasses implement rewrite and hide;
When you invoke an object method with a reference that matches the type of the object, the result is the same, but when you invoke the method in the object through a reference to the base class, overriding and hiding is completely different; overriding (override) can still find GetString (), which is defined in the object's true type, while hiding (new) The method in the base class is called;
Overloading is the method of having the same name and return value with different parameter lists, which is the ideal method to implement polymorphism;
* Why does calling virtual methods in a constructor cause problems?
The invocation order of the type construction method:
The initial expression of son's initialization expression->father the->father construction method->son the constructor method;
The problem with calling the virtual method in the construct (insufficient comprehension): When the virtual method is called in the constructor of the base class, his type still retains the subclass type, and the virtual method of the subclass is executed, and the constructor of the subclass is not completed, and any access to the subclass construction member will produce an exception; avoid the method, Never call a virtual method in a non-leaf-like construction method;
* Declaring that a class cannot be inherited (sealed); 3 Problems with inheritance:
In order for the derived type to be serialized smoothly, the non-leaf class needs to implement the appropriate serialization method;
When non-leaf classes implement interfaces such as icloneable, it means that all derived classes are forced to implement the methods in the interface as well;
A virtual method cannot be called in the constructor of a non-leaf class, nor should the this pointer be passed to other objects and methods;

4. Handling of exceptions
* Capture for different anomalies;
Try,catch (NullReferenceException) {handleexpectedexception (can be processed in the current class); Throwex (can be thrown to the upper layer); Handlecrash () { System.threading.thread.currentThread.Abort ();}};
Pay attention to the exception must inherit from the exception, form the habit of dealing with the exception separately;
* Use conditional features: Debug and Release,debug. Assert ();
Used to write a method that runs in a specific compiled version [Conditional ("DEBUG")]
* Avoid the exception of type conversion; use As,is (note that as performance is higher, reduce one attempt);

5. Interview the real problem
* What is the use of virtual methods? How does it differ from the interface? When its derived class (typically multiple, draw of the shape, round, rectangle draw) has a different implementation time; it is not the same as the interface, it is the method that the derived type has, while the virtual method is a longitudinal concept, and the interface is a horizontal concept;
* Value type and reference type are different? In memory, the allocation space is different, the former is a stack, the latter is a heap;
* How to understand static variables? It is an alternative to a global variable, such as the number of times an object of a record class is created, such as application in an ASP.
* How a type can be used in foreach: Implements the IEnumerable interface;
*new usage: New object and call constructor, use public new voidtostring () when hiding methods of base class, to constrain possible type parameters in generic declarations;
*sealed Modified class: Cannot be inherited;
Can I directly manipulate the memory in the *c#? (yes, by default, you can define an unsafe context that can use pointers by adding the unsafe keyword);
What is the #.net error handling mechanism? Should be exception handling, Try,catch ... (different catches are used for different exception, different captures for different exceptions), finally;
#面向对象语言具有那些特性? Encapsulation, inheritance, polymorphism;
#.net the mechanism of garbage collection? GC, generational; by using algorithms to find objects that are no longer being used, moving objects keeps the objects that are still being used on one side of the managed heap (that is, the previous generation, generation) and adjusts each state variable, and the execution of the Destructor method calls Finalize ();

#类成员有哪几种访问性 Public, protected,private;internal (assemble), internalprotected (assemble&family);
#什么使用Assert, in the debug program, you need to debug, Echo prompt information is used;

-Part III string, collection, stream
1. String processing
*system.string: is a reference type, its object cannot be modified after initialization, any modification of the string will result in a new string generation;
*system.stringbuilder: Because of the non-modification of the string type, for performance needs, by using the constructor design pattern (to solve the problem of creating complex objects), StringBuilder can also be used to interact with unmanaged code;
Conversion of *string and byte[] objects;
Bit, byte, encoded;
Code: Utf-8,gb2312,utf-7,unicode;
Uft-8: The character is encoded in a sequence of 1-6 8bit bytes. The number of bytes is n: If n=1, the byte high is 0, the other 7-bit encoding, if n>1, the initial byte high n bit is 1, the next one is 0, the remaining digits are used for encoding, the left byte high is 1, the next one is 0, the remainder is encoded;
*BASE64 encoding: Used to confuse 8-byte stream, but not encryption;
algorithm, separate all bits, then fill 0 in the High 2 bits, then fill the lower 6 bits;
Try{convert.tobase64string (bytes), frombase64string (base64)}catch{}
*securestring Distribution and Release: Special occasions, safe strings can play a significant role;
Use reason: String even encrypted, also reside in memory for a long time;
Public unsafe static void Printsecurestring (SecureString ss) {
char* buffer=null;//c# in the hands of a good example
try{
can only access SecureString by character
Buffer= (char*) Marshal.sercurestringtocotaskmemunicode (ss);
for (int i=0;* (buffer+i)! = ' + '; i++)
Console. Write (* (buffer+i));
}finally{
if (buffer!=null)
Marshal.zerofreecotaskmemunicode ((system.intptr) buffer);
}
}
* What is the string pooling mechanism?
Because of the immutability of strings, the use of the same string in the program consumes a lot of memory.
When the CLR starts, a string container is created, the container's key is the contents of the string, the value is a reference to the string, and when the string is used, it is found in the string pool, and if the same value exists, the reference is returned, otherwise the string is created and the reference is returned;
The mechanism can be controlled by the Assembly meta-data; system.runtime.compilerservices.compilationrelaxtionsattribute/nostringinterning;

2. Common collections and generics
*int[] is a reference type or a value type? must be a reference, the array is a family type, inherits from the System.Array;
* How to convert between arrays?
Type conversion mechanism: An array containing a value type cannot be implicitly converted to any other type; two arrays can be converted to each other in the same way; [,] with {"A", "B"},arraytypemismatchexception;
When content is converted: Use Array.convertall (-,-(will use anonymous objects, delegates, etc.));
* Generics (also known as open type, cannot be instantiated, it is recommended that parameter names start with T);
Note: Providing an instance of a generic for an open type causes the generation of a new enclosing type, but this does not mean that the new enclosing type and the open type have any derived inheritance relationships, in fact, the two are at the same level;

* What are the primary and secondary constraints of generics?
Each generic parameter can have a major constraint, the primary constraint of the generic is that the generic parameter must be or inherit a reference type, there are two special constraints: Class,struct, which represents the generic parameter is a reference type or value type;
Each generic parameter can have an infinite number of secondary constraints, which stipulate that the generic parameter must implement all the secondary constraints specified by the interface;
*.net whether the standard Template Library can be used;
STL: (algorithm,container,iterator) Wintellect team to provide;

3. Streaming and serialization (emphasis)
* What is a stream and which flows are in. Net?

Examples of use of streams: (note C # Default access level Class,method,field is internal,private,private respectively)
Class usestream{
//
Static byte[] ReadAllBytes (Stream stream, int bufferlength) {
byte[] buffer = new Byte[bufferlength];
List result = new List ();
int read = 0;
while (read = stream. Read (buffer, 0, Bufferlength) > 0)
{
Read the Last
if (read < Bufferlength) {
byte[] temp = new Byte[read];
Array.copy (buffer, temp, read);
Result.addrange (temp);
}else result.addrange (buffer);
}}
//
static void WriteAllBytes (Stream stream, byte[] data,intbufferlength) {
byte[] buffer = new Byte[bufferlength];
for (Long i=0;i
int len = bufferlength;
Write to the last
if (i+bufferlength>data. Longlength)
len = (int) (data. LONGLENGTH-I);

Array.copy (Data,i,buffer,0,len);
Stream. Write (Buffer,0,len);
}}
//
Private Const int bufferlength = 1024;
static void Main (string[] args) {
String filename= "C:\\teststream.txt";
String filecontent=getteststring ();
try{
Create and write files
using (FileStream fs = new FileStream (filename,filemode.create)) {
Byte[] Bytes=encoding.default.getbytes (filecontent);
WriteAllBytes (fs, Bytes, bufferlength);
Fs.close ();
}
Read files and print
using (FileStream fr = new FileStream (Filename,filemode.open))
{
Byte[] result= ReadAllBytes (FR, bufferlength);
Console. Write (Encoding.Default.GetString (result));
}}
finally{
try{
if (file.exists (filename))
File.delete (..);
Finally{console. Read ();
}}}}
//
Static String getteststring () {
StringBuilder builder = new.
for (int i=0;i<10;i++)
Builder. Append ("This is the test data \ r \ n");
}}
Note: The stream type implements the Idisposeable interface, which can be used to ensure that the Dispose method is called;
* How to use compressed flow: SharpZipLib component algorithm is better, system.io.gzipstream/deflatestream system comes with low efficiency;
The function of *serializable characteristics; thinking: Flow types can easily manipulate various byte streams, but how do existing instances convert to byte streams?
Serialization of object instances: refers to converting instance objects into streams that can be easily stored, transmitted, and interacted; in. NET, when a type is declared as Serializable, It can be serialized and deserialized by type objects such as BinaryFormatter that implement the IFormatter interface.
[Serializable] [Nonserializable]
Example:
Class useserializable{
public static byte[] Serialize (MyObject obj) {
IFormatter format = new BinaryFormatter ();
using (MemoryStream ms = Newmemorystream ())
{
Format. Serialize (MS, obj);
Return Ms. ToArray ();
}}
public static MyObject deserialize (byte[] data) {
IFormatter format = new BinaryFormatter ();
using (MemoryStream ms = new MemoryStream (data)) {
Return (MyObject) format. Deserialize (MS);
}}
static void Main (string[] args)
{
MyObject MYOBJ = new MyObject ("Baoshan");
Console.WriteLine ("Before");
Console.WriteLine (MYOBJ);
byte[] temps = Serialize (MYOBJ);
MyObject NEWOBJ = Deserialize (temps);
Console.WriteLine ("after");
Console.WriteLine (NEWOBJ);
Console.read (); } }
*.net provides put into serializable types: Binaryformatter,soapformatter,xmlserializer
BinaryFormatter: Serializes a serializable object into a binary byte stream;
SoapFormatter is dedicated to serializing serializable types into XML documents that conform to the SOAP specification;

XmlSerializer: You must have a public construction method that is not a parameter, only the public member variable can be serialized; The XmlIgnore property is created with the type of object to be entered, Xmlserializerxs = new XmlSerializer (typeof (MyObject));
object, byte stream, specifying the encoded string;
Xmlns:soap-enc= "http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap-env= "http://schemas.xmlsoap.org/soap/envelope/".
* How to customize the serialization and deserialization process: the need to implement the ISerializable interface, to provide a specific re-deserialization of the method of building the object, usually the constructor for security reasons, cannot be set to public, which is why the method is not defined in the interface reason; GetObjectData and special construction methods have two parameters, SerializationInfo is equivalent to a hash table, and Streamcontext records the state of the current stream;

5. The name Enterprise interview real problem;
* Complement: What is the difference between a generic call and an explicit invocation of an interface? The benefit of an explicit invocation: a hidden implementation; In a system accessed by an interface, it can only be called through an interface rather than the underlying class;
* How to copy an array to ArrayList, and vice versa? ArrayList Dynamic array: Easy to add delete elements (sequential table, linked list); dynamically allocate size; implement Icollection,ilist interface; Convert: Arraylist.toarray (typeof (...)) /copyto (Array); Arraylist.adapter (Array);
*string Str=null and Stringstr= "" What is the difference? The former: There is no space allocated in the heap, the latter allocates space in the heap, but the contents in the space are empty;
*stringbuilder function: Since the string type in. NET cannot be changed once initialized, if you want to do a lot of basic operations of strings (such as stitching), you will create a lot of temporary strings, a lot of memory consumption; StringBuilder well built to solve this problem, dynamically change the string, and finally use the ToString () method to return the desired string; The default size is 16;
Note: Because there is a private string type variable in the StringBuilder, and in the process of assembly, the variables in memory change, conform to the unmanaged code string type modifies the memory characteristics, can be used to interact with the unmanaged type;
* The benefits of generics: Reduce the Disassembly box, improve performance, ensure type safety;
* owns string array {"2", "3", "4"}, how to convert to an integer array: basic traversal transformation; Array.convertall (...)
* What is serialization?. How is serialization implemented in net? Serialization is the conversion of the object into a certain format of the byte stream, convenient cross-domain operation, labeling serializable characteristics, using XmlSerializer type;
* What is encoding? What is Unicode? Encoding refers to the form of a representation of characters, there are many international standards such as UTF-8,UNICODE,ASCII, our country also has GB2312 and so on. Unicode is an internationally-accepted encoding and is widely adaptable;
Accurate version: The conversion mechanism of digital information and real information, a coding definition of a character set and the principle of conversion;
*base64 use occasions? Mainly used for network transmission of data. Like e-mail? Solve the problem of network transmission codes, but it is not a cryptographic mechanism;
* How does a string pool improve system performance? The CLR provides a string pooling mechanism. When the CLR starts, it creates a container that stores strings, that is, a string pool, and whenever you want to create a new string, it looks in the pool first, if there is a string of the same content, if you have a direct return reference, and if not, create a new one and return the reference. This can save a lot of memory consumption when a large number of repeated strings are used;
* What is the difference between a cryptographic string and a normal string? The encrypted string is also ciphertext in memory, preventing it from being read directly from memory (when it operates on its own); Although the string can also be encrypted, it may reside in memory and can also be used to interact with unmanaged code;

-part fourth common classes and interfaces
*system.object: Through the ILasm.exe noautoinherit switch, you can generate types that do not inherit from System.Object, which is not a secure type and is not advocated for use. However, the existence of such a mechanism, the programmer can not arbitrarily the object defaults to System.Object; What we can do is to catch all the anomalies;
Similarities and differences between the 3 comparison methods of *object:
The static method ReferenceEquals implements a reference comparison, and if the value type is never true, even the same variable, think of the Disassembly box. Static equals implements a more efficient invocation of the instance of the Equals method. An instance of the Equals method is a virtual method, and the default implementation is a reference comparison, where you can actually override the Equals method as needed. The base class of the value type System.ValueType overrides the Equals method and implements the content comparison;
* Rewrite GetHashCode method (difficult, temporary qualitative understanding):
The GetHashCode algorithm in object guarantees that the same object returns a uniform hashcode, while different objects return different hashcode, but the default GetHashCode algorithm is incorrect for objects with the same object as value types, such as equal objects;
overriding GetHashCode must guarantee 3: The same object will return uniform hashcode whenever it is returned, and equal objects must return the same value. On this basis, the hashcode is guaranteed to be randomly distributed;

2. Time Operation System.DateTime
*datetime How to store time: the internal storage of a 64-bit long integer, where the low 62-bit represents the time, representing the number of nanoseconds from January 1, 01 0:0 to 0 seconds to the time elapsed; High 2 bits, storing the UTC flag;
*datetime object and string Object conversion: Use ToString to format a DateTime object to a string. Instead, use Parse,tryparse to construct a DateTime object from a string;
String s = "2014-3-16 19:50:00";
DateTime DT;
if (Datetime.tryparse (S, Outdt)) {
Console ... (DT);
}
*UTC time: Greenwich Mean Time (GMT), which is the time measured at 0 degrees longitude. The ToUniversalTime and Tolocal methods allow you to convert between local time and UTC time. Two methods in the conversion will be set to save the time of the high 2-bit flag, and the conversion algorithm to consider the summer season;
Note: Summer season, daylight saving time, energy saving; daylight saving (daylight saving time:dst);
*iformattable and IFormatProvider use, (NUT): Because sometimes the ToString method without parameters can not meet all the needs of the format, you need to consider implementing the IFormattable interface; Example:
public string ToString (string format, Iformatproviderprovider) {
if (provider!=null) {
ICustomFormatter FMT = provider. GetFormat (this. GetType ()) Asicustomformatter;//this->useiformattable:iformattable
if (fmt!=null) return FMT. Format (format, this,provider);//The feeling that gives me is flexible and has a sense of handling according to the current type and format string. Just want to change provider in the frame, is that what this means? }}
Precautions:
Implementing IFormattable.ToString () can customize several of the format strings, but there are 3 strings that should be implemented: "G", Null,empty, because of the. NET built-in specification;
When IFormattable.ToString () is implemented, all built-in types will call IFormattable.ToString () instead of the System.Object ToString (); more difficult to understand;
The built-in method automatically calls IFormattable.ToString (), using a parameter that is either "G" or an empty string, so the output of object.tostring () is uniform at design time.
At the beginning, the IFormatProvider is checked to enable the type provider to provide a formatted method ... It has a frame of taste;
* Type format output method: IFormatProvider function, iformatable interface implementation, IFormatProvider and IFormattable interface common use, so that the type designer to achieve some of the commonly used formatting requirements, and allow users to provide their own format method, more flexible;
* Manage the types of files and folders: Fileinfo,directoryinfo;
File and FileInfo difference: FileInfo can touch a file to generate a specific instance, and file is a static class; FileInfo is committed to manipulating the structure of files in the file system, while file is dedicated to the read and write operations of the files themselves;
Note: Because FileInfo and DirectoryInfo involve contention for resources and cannot ensure that files and folders exist or not, they generally need to be placed in try,catch,finally;
* How to implement file and folder monitoring: Using Filesystemwatch for file system monitoring, you can easily monitor by setting up the monitoring directory, monitoring type and callback method. However, care should be taken to filesystemwatcher cache overflow;

Timers in 5.net:
System.Windows.Forms.Timer; used for form design, and runs on the form thread, resulting in timing inaccuracies and missed beats; when it is constructed, it is associated with the yourselves thread, and when the timer's timing arrives, a message from the timer is inserted into the message queue of the current thread. The current thread processes all messages in the message queue and sends them to their respective processing methods. Such a mechanism and the use of worker threads are very different, in fact, the type does not involve multi-threaded operation, timer settings, timing method of execution are on the same thread;
System.Threading.Timer; Each timing callback is executed on the worker thread, and the timing is relatively accurate;
Threadtimer = new System.Threading.Timer (NewSystem.Threading.TimerCallback (Threadtimerhandler), NULL, System.threading.timeout.infinite,system.threading.timeout.infinite);
Threadtimer.change (Interval,interval);
System.Timers.Timer; is System. Threading.timer of a packaging, design backward, not recommended to use;
*.net the built-in type of timer will occur callback method re-entry;
Method re-entry: is a multi-threaded programming concept, when more than one thread in a program executes, it is possible that the same method is called by multiple threads; When there are some non-thread-safe code in this method, there may be inconsistent data and serious bugs.
Form.timer single thread, will not appear;
Threading.timer: The callback method executes on the worker thread, and whenever the timer occurs, the thread that controls the timer is responsible for assigning a new worker thread from the thread pool, the method is re-entered, the synchronization needs to be considered, and lock is used in the callback method. Puzzle

6. The name Enterprise interview real problem;
*datetime.parse (myString); What's wrong with the code? may be abnormal, should be avoided with TryParse;
What's the difference between *equals,==,referenceequals? Equals is the basic method, if the system default value type compares the content, the reference type compares the reference, and can be overridden; = = "is a comparison tradeoff (when referring to a type when compared to a reference, value type is more tolerant); ReferenceEquals comparison reference;
* Briefly describe the conversion algorithm for datetime and long integer types. The high 2 bits are the UTC flag bit, and the low 62 bits are timestamps (January 01, 01 00:00 00 seconds);
Private Long Internalticks{get ({return (long) this.datedata&0x3fffffffffffffffl}};
* Conversion of local time and UTC time: The ToUniversalTime and Tolocal methods can be converted between local time and UTC time; Datetimedt = new DateTime (DateTime.Now, DATETIMEKIND.UTC);
*gethashcode the role of the method, when to use it? Obtain hash code for the comparison of different objects of the same type, set operation and other situations;
Also note 3 points: uniform objects at any time hashcode should be the same, different objects of the same type if the values are the same, hashcode should be the same; hash as possible (randomly distributed);
*.net What kinds of timers are available, and how do they work? 3: Form.timer, the same process as the UI, prone to errors; Threading.timer whenever a timer is triggered to create a worker process in the thread pool, timing is accurate, but there is a method to re-enter the problem, can be resolved synchronously; Timers.timer, package threading.timer, obsolete;
* Why design System.Object? The type inherits the class by default, which allows the code to be managed, and the CLR can help to do a lot of things handy for programmers;
* Talk about the location of formatted output: time, date, currency, letter; globalization,localization,translation;
* Recursive
* Bubble Sort

. NET Work Preparation--02 basics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.