. NET written examination sharing and. net written examination sharing
I have been interviewing for a long time, and I am not very prepared before each interview. Although most of the questions I have encountered are very simple, I am too nervous to answer questions on the site, some questions are not very well answered, so you can think about how to answer them each time you come back;
Most of the questions are quite simple. First, record a few things that you remember in your mind.
1. Create an array with a length of 100 and insert 1-Unique Numbers randomly. This question should have been written as follows:
static int[] Fun(){ int[] arr = new int[100]; int index = 0; Random ran = new Random(); while (index < 100) { int temp = ran.Next(1, 101); if (!arr.Contains(temp)) arr[index++] = temp; } return arr;}
Later, I went home and thought about it. This is not a good writing, because after a random number is generated each time, I can determine whether the array contains this. If it does not contain this number, I can insert the array. In this way, as the number in the array is increasing, the number of times to be judged will also increase. Change it:
static int[] Fun(int begin, int len){ ICollection<int> oldArr = new List<int>(); for (int i = begin; i <= len; i++) { oldArr.Add(i); } int[] newArr = new int[len - begin + 1]; Random ran = new Random(); int index = 0; while (oldArr.Count() > 0) { int temp = oldArr.ElementAt(ran.Next(0, oldArr.Count())); newArr[index++] = temp; oldArr.Remove(temp); } return newArr;}
A set with a specified range, randomly Add the subscript of the set to the array, and then delete the elements in the set. In this way, you don't need to make so many judgments. Just traverse twice.
2. 1-2 + 3-4 + 5... + M is used to evaluate the result of this expression.
I only wrote this in the written test. At that time, my mind was blank, and I didn't know how to write it after recursion.
static int Fun2(int Num){ int i = 1; int result = 1; while (Num > i) { if (i % 2 == 0) result += ++i; else result -= ++i; } return result;}
Let's go home and think about how stupid I was at the time. I didn't write such a simple recursion ..
static int Fun(int Num){ if (Num == 1) return 1; if (Num % 2 == 0) return Fun(Num - 1) - Num; else return Fun(Num - 1) + Num;}
3. What is the result of Class B being instantiated?
class A{ public A() { Display(); } public virtual void Display(){}}class B : A{ int x = 1; int y; public B() { y = 2; } public override void Display() { Console.Write(string.Format("x={0},y={1}", x, y)); }}
The result is x = 1, y = 0. When the class is instantiated, the parent class constructor is called, that is, the top parent class constructor is called first, then, the sub-class constructor is called in sequence. In this question, the constructor is executed first. The constructor of A calls the Display method. Because this method is overwritten by the quilt class, it is called after rewriting. At this time, X = 1. Since the constructor of B has not been called, the value of Y is the default value 0 when stack space is allocated. So the final result is x = 1, y = 0.
Many questions are encountered during the written examination, most of which are poorly forwarded on the Internet, and the company has very few questions. Record these three questions today, and continue later;
What are the issues with the NET interview test?
This interview question is generally obtained by the company...
0. What is object-oriented
Object-oriented OO = Object-Oriented Analysis OOA + object-oriented design OOD + Object-Oriented Programming OOP;
The general interpretation is that everything is an object, and all things are considered as independent objects (units). They can complete their own functions, rather than dividing them into functions like C;
The pure OO language is mainly java and C #. C ++ also supports OO, and C is process-oriented;
1. Briefly describe the access permissions of private, protected, public, and internal modifiers.
A. private: private Members can be accessed within the class.
Protected: protects members, which can be accessed within the class and in the inheritance class.
Public: A public member. It is completely public and has no access restrictions.
Internal: accessible within the same namespace.
2. List several methods for passing values between ASP. NET pages.
Answer. 1. Use QueryString, such ....? Id = 1; response. Redirect ()....
2. Use Session Variables
3. Use Server. Transfer
3. the rules for a column are as follows: 1, 1, 2, 3, 5, 8, 13, 21, 34 ...... calculate the number of 30th digits and use a recursive algorithm.
A: public class MainClass
{
Public static void Main ()
{
Console. WriteLine (Foo (30 ));
}
Public static int Foo (int I)
{
If (I <= 0)
Return 0;
Else if (I> 0 & I <= 2)
Return 1;
Else return Foo (I-1) + Foo (I-2 );
}
}
4. What is the delegate in C? Is an event a delegate?
A:
A delegate can substitute a method as a parameter into another method.
A delegate can be understood as a reference to a function.
Yes, it is a special delegate
5. Differences between override and overload
A:
The difference between override and overload. Overload means that the method name is the same. The parameters or parameter types are different and are reloaded multiple times to meet different needs.
Override is used to Override functions in the base class. To meet your needs.
6. If you need to pass variable values in a B/S system, but you cannot use Session, Cookie, and Application, how can you handle them?
A:
This. Server. Transfer
7. programmatically traverse all TextBox controls on the page and assign it a string. Empty?
A:
Foreach (System. Windows. Forms. Control control in this. Controls)
{
If (control is System. Windows. Forms. TextBox)
{
System. Windows. Forms. TextBox tb = (System. Windows. Forms. TextBox) control;
Tb. Text = String. Empty;
}
}
8. How can I program a Bubble sorting algorithm?
A:
Int [] array = new int [*];
Int temp = 0;
For (int I = 0; I <array ...... remaining full text>
Net pen exam
Baidu. net interview questions... General pen questions are those.