After years, ready to find a new job, although the hands of the work is good, but the tree moved to death, people move. I can not always live in a pit for a lifetime, the outside world is very good after all.
In order to be able to find their favorite job, recently, all the basic knowledge has been taken out to review. Only record, encourage each other, you God don't spray, feel free to look at it.
The following knowledge points are excerpted from the questions encountered during the interview
1.try{} There is a return statement, then the finally{} immediately following the try will not execute?
Answer: Execute, execute after return
students 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 ();
}
}
It's a mnemonic type, and it's best to understand the principle.
What is the use of 2.Using?
A: Many students see this on the smile, is not the namespace of the quote, as everyone knows, the question is waiting for you more wonderful answer.
The using also enables the release of unmanaged resources, implements the Idisposiable class in the using, and automatically calls the Dispose method to reclaim the resource after the using end, which is equivalent to try...finally
The above can be consulted: http://www.cnblogs.com/miniwiki/archive/2010/05/13/1734307.html
This time the interviewer laughed, Mianlicangzhen asked, what is unmanaged resources, managed resources. At this point, I was exposed to the endorsement.
Managed resources: generally refers to memory resources that are controlled by the CLR, which are managed by the CLR. Can be thought of as a resource in a. NET class library.
Unmanaged resources: Resources that are not controlled and managed by the CLR, such as file streams, database connections, network connections, System window handles, printer resources, and so on, are generally not present on the heap. A set of APIs that can be considered operating system resources.
For managed resources, the GC is responsible for garbage collection. For unmanaged resources, the GC can track the lifetime of an unmanaged resource, but does not know how to release it, and it is manually released.
The interviewer will then continue to ask the GC recycling mechanism Bharara a big push until you can't answer it.
3.Readonly with const difference
Is it simple again?
First, explain what the static constants are and what the dynamic constants are. A static constant is a compiler that parses a constant at compile time and replaces the value of the constant with the initialized value. While the value of the dynamic constant is obtained at the moment of operation, it is marked as a read-only constant during compiler compilation, instead of the constant value, so that the dynamic constant does not have to be initialized at the time of declaration, but can be deferred to the constructor initialization.
Basic understanding of the above, you can be the seat. Const-Modified constants are the first of these, static constants, while ReadOnly is the second, dynamic constant. Then the difference can be explained by the characteristics of static constants and dynamic constants.
1) const-modified constants must be initialized at the time of Declaration; readonly-Modified constants can be deferred to constructor initialization
2) const-modified constants are parsed during compilation, that is, constant values are replaced with initialized values; readonly-Modified constants are deferred until run time
In addition, const constants can be declared either in a class or within a function body, but static ReadOnly constants can only be declared in a class.
Above excerpt from: http://www.cnblogs.com/royenhome/archive/2010/05/22/1741592.html
The above is the focus of today's observation, perhaps very basic, perhaps many times reunion, warm so know new bar
Pre-Interview Preparation---C # knowledge point review----01