Preparations before the interview --- C # knowledge Review ---- 01,

Source: Internet
Author: User

Preparations before the interview --- C # knowledge Review ---- 01,

After the year, I was ready to find a new job. Although I had a good job in my hand, I had to move the tree to death and move people to work. We cannot keep living in a trap for a lifetime. the world outside is beautiful after all.

In order to find my favorite job, I recently reviewed all the basic knowledge. Record-only, self-encouragement, don't spray, just look at it at will.

The following knowledge points are taken from questions encountered during the interview.

1. If there is a Return statement in try {}, will the Finally {} followed by try be executed?

Answer: Yes. It will be executed after Return.

Those who like to study thoroughly can refer to: http://www.cnblogs.com/forcertain/archive/2012/11/22/2782855.html

My memory method is as follows:

Public static int ExecuteNonQuery (string connStr, string SQL)
{
OleDbConnection conn = null;
Try
{
Conn = new OleDbConnection (connStr );
Conn. Open ();
OleDbCommand command = new OleDbCommand (SQL, conn );
Return command. ExecuteNonQuery ();
}
Catch
{
Return 0;
}
Finally
{
Conn. Close ();
}
}

This is a helpful memory type. It is best to understand the principle.

2. What is the use of Using.

A: A lot of people laugh when they see this. It's not just the reference of namespace. I don't know, but the speaker is waiting for you to give a better answer.

Using can also release unmanaged resources and create IDisposiable classes in Using. After Using is complete, the Dispose method is automatically called to reclaim resources, which is equivalent to try... finally.

The above can be referred to: http://www.cnblogs.com/miniwiki/archive/2010/05/13/1734307.html

At this time, the interviewer smiled and asked, "What is a non-Managed Resource? hosting resources?" If you cannot answer this question, your endorsement will be exposed.

Managed resources: generally refers to the memory resources controlled by CLR, which are managed by CLR. It can be considered as a resource in the. net class library.

Unmanaged resources: resources that are not controlled and managed by CLR, such as file streams, database connections, network connections, system Window handles, and printer resources. These resources are generally not stacked. A group of APIs that can be considered as operating system resources.

GC is responsible for garbage collection for managed resources. For unmanaged resources, GC can track the lifetime of the unmanaged resources, but does not know how to release it. At this time, manual release is required.

Then, the interviewer will continue to ask about the GC recovery mechanism balara, until you cannot answer the question.

3. Differences between Readonly and Const

Is it easy again?

First, explain what is a static constant and what is a dynamic constant. A static constant is a constant that is parsed by the compiler during compilation and replaced with the initial value. The value of a dynamic constant is obtained at the moment of running. during compilation, it is marked as a read-only constant instead of a constant value, in this way, Dynamic Constants do not need to be initialized during declaration, but can be delayed to initialization in the constructor.

After learning about the above, you can get a seat on the number. The constant modified by const is the first one in the preceding section, that is, the static constant, and readonly is the second one, that is, the dynamic constant. The difference can be illustrated by the characteristics of static constants and dynamic constants.

1) const-modified constants must be initialized during Declaration; readonly-modified constants can be delayed until the constructor is initialized.

2) const-modified constants are parsed during compilation, that is, the constant value is replaced with the initial value. readonly-modified constants are delayed until running.

In addition, the const constant can be declared in the class or in the function body, but the static readonly constant can only be declared in the class.

From: http://www.cnblogs.com/royenhome/archive/2010/05/22/1741592.html

These are the important observations of today. They may be very basic and may have been reunited for many times. Let's learn new things for a warm time.

Related Article

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.