. Net basic knowledge

Source: Internet
Author: User
Arraylist object
The arraylist object is thread-safe during implementation and supports multiple read processes for operations without modification. However, if you use an enumerator, the multi-thread security issue may occur. Because the enumerator is NOT thread-safe, you need to lock it when using the enumerator.

ProgramSet file dll/EXE and assembly list assembly
The Assembly file mainly includes:
Assembly List
Type metadata
Microsoft intermediate language
Other resources.

The Assembly list mainly includes:
Assembly name
Version Information
Region Information
Strong name information
Assembly file list
Type reference information
Reference and dependent assembly information

Dllimport attributes
The dllimport attribute is mainly used to import unmanaged data.CodeFor example, to call a function written in C/C ++ in C #, you need to use the dllimport attribute, which is required for many winapi calls.
Dllimport has four attributes:
Entrypoint: indicates the DLL file from which the function is generated, that is, the file on which the DLL entry function is located.
Charset: This attribute is used to control name and string serialization .. Net Framework supports charset: auto, Unicode, none, and ANSI in four modes. The default charset of frameworks of different versions may be different. The compact version is Unicode, while the normal version is ANSI.
Callingconvention: This attribute specifies the specifications used for DLL export functions. We know that the DLL functions include _ stdcall, _ fastcall, _ cdecl, and _ declspec. We can set this attribute based on the corresponding DLL. However, in most cases, the exported API in wins is the _ stdcall standard, so the default value set by framwork is winapi. This will be automatically converted on ce and normal versions.
Setlasterror: Anyone who has used winapi knows that wins has a getlastwin32error API, so this property corresponds to it. If the function call fails, the operating system will set an error number. In C #, the default value is false.

Foreach and
As we all know, foreach is a convenient keyword provided by C # For traversing members. However, the target object must be a collection object, such as list and array. Of course, it can also be a self-implemented object, but it must inherit the ienumerable interface and ienumerator interface. So what is the difference between for and foreach?
For (INT I = 0; I <array. length; I ++)
Do something...

For (int I in array)
Do something...
We know that the ienumerator interface needs to implement movenext and current.
Public BoolMovenext () // Return Value Check
{
Position ++;
Return(Position <_ people. Length );
}

Public Object current // function call
{
Get
{
Try {
Return _ People [position];
}
Catch (Indexoutofrangeexception)
{
Throw New Invalidoperationexception ();
}
}
}
From the two functions, we can see that using foreach requires at least one bool check and one function call than. This efficiency is much lower when we calculate a large amount of data.

Data Access Application Block for. net
This is a class of sqlhelper, which is useful for database access. It encapsulates most of the common operations on ado.net, saving you from a lot of rewriting troubles.
For more information, see here.

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.