Home  >  Article  >  Backend Development  >  ASP.NET interview questions collection

ASP.NET interview questions collection

怪我咯
怪我咯Original
2017-03-30 14:02:121137browse

ASP.NET interview question collection

1. Briefly describe the access rights of private, protected, public, and internal modifiers.
Answer. private: Private members can only be accessed inside the class.
protected: Protected members, accessible within the class and inherited classes.
public: Public members, completely public, no access restrictions.
internal: Accessible within the same namespace.

2. List several ways to transfer values ​​between ASP.NET pages.
Answer. 1. Use QueryString, such as....?id=1; response. Redirect()....
2. Use Session Variable
3. Use Server.Transfer

3. The rules for a column of numbers are as follows: 1, 1, 2, 3, 5, 8, 13, 21, 34.... .. To find out what the 30th digit is, use the recursive algorithm to implement it.
Answer: 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 delegation in C#? Event Is it a kind of delegation?
Answer:
A delegate can substitute one method as a parameter into another method.
A delegate can be understood as a reference pointing to a function.
Yes, it is a special kind of delegation

5. The difference between override and overloading
Answer:
The difference between override and overloading. Overloading is a method with the same name. If the parameters or parameter types are different, multiple overloading is performed to meet different needs.
override is the rewriting of functions in the base class. To adapt to needs.

6. If you need to pass variable values ​​in a system with a B/S structure, but Session, Cookie, and Application cannot be used, how many methods do you have to handle it?
Answer:
this.Server.Transfer

7. Please programmatically traverse all TextBox controls on the page and assign it a value of string.Empty?
Answer:
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. Please program to implement one Bubble sortAlgorithm?
Answer:
int [] array = new int
;
int temp = 0;
for (int i = 0; i < array.Length - 1; i++)
{
for (int j = i + 1 ; j < array.Length ; j++)
{
if (array [j] < array [i])
{
temp = array [i] ;
array [i] = array [j] ;
array [j] = temp ;
}
}
}

9. Describe the implementation process of index in C#. Can it only be indexed based on numbers?
Answer: No. Any type can be used.

10. Find the value of the following expression, and write down one or several implementation methods you think of: 1-2+3-4+……+m
answer :
int Num = this.TextBox1.Text.ToString() ;
int Sum = 0 ;
for (int i = 0 ; i < Num + 1 ; i++)
{
if((i%2) == 1)
{
Sum += i ;
}
else
{
Sum = Sum - I ;
}
}
System.Console.WriteLine(Sum.ToString());
System.Console.ReadLine();

11. Use .net to build a B/S structured system. Is it developed using several layers of structure? What is the relationship between each layer and why is it layered like this?
Answer: Generally there are 3 layers
Data access layer, business layer, and presentation layer.
The data access layer performs additions, deletions, checks and modifications on the database.
The business layer is generally divided into two layers. The business appearance layer implements communication with the presentation layer, and the business rule layer implements security of user passwords, etc.
The presentation layer is used to interact with users, such as users adding forms.
Advantages: Clear division of labor, clear organization, easy debugging, and scalability.
Disadvantages: Increased cost.

12. In the following example
using System;
class A
{
public A()
{
PrintFields();
}
public virtual void PrintFields(){}
}
class B:A
{
int x=1;
int y;
public B()
{
y=-1;
}
public override void PrintFields()
{
Console.WriteLine("x={0},y= {1}",x,y);
}
What output is produced when using new B() to create an instance of B?
Answer: X=1,Y=0;x= 1 y = -1

13. What is an application domain?
Answer: The application domain can be understood as a lightweight process. Play a safety role. It takes up little resources.

14.What are the explanations for CTS, CLS and CLR?
Answer: CTS: Common Language System. CLS: Common Language Specification. CLR: Common Language Runtime.

15.What are boxing and unboxing?
Answer: Convert from value type interface to reference type boxing. Type conversion from reference to value type unboxing.

16.What is regulated code?
Answer: unsafe: unmanaged code. Run without going through the CLR.

17. What is a strong type system?
Answer: RTTI: Type Identification System.

18. What classes are needed to read and write databases in .net? Their role?
Answer: DataSet: data storage.
DataCommand: Execute statement command.
DataAdapter: A collection of data, filled with words.

19.What are the authentication methods of ASP.net? What are the differences?
Answer: 10. Windows (default) uses IIS...From (form) uses account...Passport (key)

20. What is Code-Behind technology?
Answer: Code post-planting.

21.In .net, what does accessories mean?
Answer: Assembly. (Intermediate language, source data, resources, assembly list)

22. What are the commonly used methods of calling WebService?
Answer: 1. Use the WSDL.exe command line tool.
2. Use the Add Web Reference menu option in VS.NET

23.. How does net Remoting work?
Answer: The server sends a process number and a program domain number to the client to determine the location of the object.

24. In C#, string str = null and string str = "" Please try to use text or images to explain the difference.
Answer: string str = null does not allocate memory space to it, but string str = "" allocates memory space with a length of empty string.

25. Please elaborate on the similarities and differences between classes and structures in dotnet?
Answer: Class can be instantiated and is a reference type, which is allocated on the heap of memory. Struct is a value type, which is allocated on the stack of memory.
26. Based on the knowledge of delegate , please complete the following code snippets in the user control:
namespace test
{
public delegate void OnDBOperate();
public class UserControlBase : System.Windows.Forms.UserControl
{
public event OnDBOperate OnNew;
privatevoidtoolBar_ButtonClick(objectsender,System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
if(e.Button.Equals(BtnNew))
{
// Please complete the code below to call the OnNew event signed by the OnDBPerate delegate.
}
}
}
Answer: if(OnNew != null)
OnNew( this, e);

27. Analyze the following code and fill in the blanks
string strTmp = "abcdefgXXXX";
int i= System.Text.Encoding.Default.GetBytes(strTmp).Length;
int j= strTmp.Length;
After the above code is executed , i= j=
Answer: i=13,j=10

28. In the SQLSERVER server, there are two fields ID and LastUpdateDate in the given table table1. ID represents the updated transaction number, LastUpdateDate Indicates the server time at the time of update. Please use a SQL statement to obtain the last updated transaction number
Answer: Select ID FROM table1 Where LastUpdateDate = (Select MAX(LastUpdateDate) FROM table1)

29. According to thread safety Relevant knowledge, analyze the following code, will it cause a deadlock when i>10 when calling the test method? And briefly explain the reason.
public void test(int i)
{
lock(this)
{
if (i>10)
{
i--;
test( i);
}
}
}
Answer: No deadlock will occur, (but one thing is that int is passed by value, so every time it changes, it is just a copy, so there will be no A deadlock occurs. But if int is replaced by an object, a deadlock will occur)

30. Briefly talk about your understanding of remoting and webservice technologies under the Microsoft .NET framework and their practical applications. .
Answer: WS can mainly use HTTP to penetrate firewalls. Remoting can use TCP/IP and binary transmission to improve efficiency.

31. The company requires the development of a component that inherits the System.Windows.Forms.ListView class and requires the following special functions: when clicking on the column header of each column in the ListView, it can be rearranged according to the value of each row of the clicked columnView## All rows in # (sorted in a similar way to DataGrid). Based on your knowledge, please briefly talk about your ideas Answer: According to the clicked column header, the ID of the column is taken out, sorted according to the ID, and then bound to the ListView.

32. Given the following XML file, complete the algorithm flow chart.

< DriverC >






< ;/DriverC>

Please draw a flow chart that traverses all file names (FileName) (please use recursive algorithm).
Answer:
void FindFile( Directory d )
{
FileOrFolders = d.GetFileOrFolders();
foreach( FileOrFolder fof in FileOrFolders )
{
if( fof is File )
You Found a file;
else if ( fof is Directory )
FindFile( fof );
}
}

33. Write a Sql statement: Take out the 31st to 40th records in table A (SQLServer, use the automatically growing ID as the primary key. Note: IDs may not be consecutive.
Answer: Solution 1: select top 10 * from A where id not in (select top 30 id from A)
Solution 2: select top 10 * from A where id > (select max(id) from (select top 30 id from A )as A)

34.
Object-oriented languages ​​have properties, _ properties, and propertiesAnswer: Encapsulation, inheritance, polymorphism.

35. Objects that can be accessed through foreach traversal need to implement interfaces or declare methods.
Answer: IEnumerable, GetEnumerator.

36. What is GC? Why is there a GC?
Answer: The GC is a garbage collector. Programmers don’t have to worry about memory management, because the garbage collector will do it automatically. To manage. To request garbage collection, you can call one of the following methods:
System.gc()
Runtime.getRuntime().gc()

37.String s = new String( "xyz"); How many String Objects were created?
Answer: Two objects, one is "xyx" and the other is a reference object s pointing to "xyx"

38.abstract class and interface. What is the difference?
Answer:
A class that declares the existence of a method without implementing it is called
abstract class (abstract class), which is used to create a class that embodies certain basic behaviors. class and declare a method for that class, but it cannot be implemented in the class. It is not possible to create an instance of the abstract class. However, it is possible to create a variable whose type is an abstract class and have it point to one of the concrete subclasses. Example. There cannot be abstract constructors or abstract static methods. Subclasses of the Abstract class provide implementations for all abstract methods in their parent class, otherwise they would also be abstract classes. Instead, implement the method in a subclass. Other classes that are aware of its behavior can implement these methods in their class. Interface is a variant of abstract class. In an interface, all methods are abstract. Multiple inheritance can be obtained by implementing such an interface. All methods in the interface are abstract and none of them have a program body. Interfaces can only define static final member variables. Implementation of an interface is similar to subclassing, except that the implementing class cannot inherit behavior from the interface definition. When a class implements a particular interface, it defines (i.e. gives the program body to) all of the methods of this interface. It can then call the interface's methods on any object of the class that implements the interface. Since there are abstract classes, it allows using the interface name as the type of the reference variable. Normal dynamic linking will take effect. References can be converted to or from interface types, and instanceof
operator can be used to determine whether an object's class implements the interface. 39. Should you use run() or start() to start a thread?
Answer: To start a thread, call the start() method to make the virtual processor represented by the thread in a runnable state
, which means it can be scheduled and executed by the JVM. This does not mean that the thread will run immediately. The run() method can stop a thread by generating a mustexit flag. 40. Can interfaces inherit interfaces? Can abstract classes implement interfaces? Can abstract classes inherit concrete classes?
Answer: Interfaces can inherit interfaces. Abstract classes can implement interfaces, and whether abstract classes can inherit entity classes, but the premise is that the entity class must have a clear constructor.

41. Can the constructor Constructor be overridden?
Answer: The constructor Constructor cannot be inherited, so Overriding cannot be overridden, but Overloading can be overridden.

42. Can the String class be inherited?
Answer: The String class is a final class and cannot be inherited.

43. There is a return statement in try {}, so will the code in finally {} immediately following this try be executed? When will it be executed, before or after return?
Answer: It will be executed before return.

44. Two objects have the same value (x.equals(y) == true), but they can have different hash codes. Is this correct?
Answer: No, they have the same hash code.

45. Can swtich act on byte, can it act on long, can it act on String?
Answer: switch(expr1), expr1 is a IntegerExpression. Therefore the parameters passed to switch and case statements should be int, short, char or byte. Neither long nor string can be used on switch.

47. When a thread enters a synchronized method of an object, can other threads enter other methods of the object?
No, a synchronized method of an object can only be accessed by one thread.

48. Can the abstract method be static, native, and synchronized at the same time?
Answer: None.

49.Do List, Set, and Map inherit from the Collection interface?
Answer: List, Set are Maps, not Map

50.The elements in Set cannot be repeated, so what should I use? What method is used to distinguish duplication? Should we use == or equals()? What is the difference between them?
Answer: The elements in the Set cannot be repeated, so use the iterator() method to distinguish duplication. equals() determines whether two Sets are equal.
The equals() and == methods determine whether the reference value points to the same object. equals() is overridden in the class in order to return a true value when the contents and types of the two separate objects match.

51.ArrayIs there a length() method? Does String have a length() method?
Answer: Arrays do not have the length() method, but have the attribute of length. String has the length() method.

52. What is the difference between sleep() and wait()?
Answer: The sleep() method is a method that stops the thread for a period of time. After the sleep interval expires, the thread does not necessarily resume execution immediately. This is because at that moment, other threads may be running and are not scheduled to give up execution, unless (a) the "waking up" thread has a higher priority
(b) is running The thread is blocked for other reasons.
wait() is when threads interact. If the thread issues a wait() call to a synchronization object x, the thread will suspend execution and the called object will enter the waiting state until it is awakened or the waiting time expires.

53.Short s1 = 1; s1 = s1 + 1; What’s wrong? short s1 = 1; s1 += 1; What’s wrong?
Answer: short s1 = 1; s1 = s1 + 1; There is an error. s1 is of type short, s1+1 is of type int, and cannot be explicitly converted to type short. It can be modified as s1 =(short)(s1 + 1). short s1 = 1; s1 += 1 is correct.

54. Talk about the difference between final, finally and finalize.
Answer:
final-modifier (keyword) If a class is declared final, it means that it can no longer derive new subclasses and cannot be inherited as a parent class. Therefore, a class cannot be declared both abstract and final. Declare variables or methods as final to ensure that they will not be changed during use. Variables declared as final must be given an initial value when declared, and can only be read in subsequent references and cannot be modified. Methods declared as final can also only be used and cannot be overloaded.
finally-provide a finally block to perform any cleanup operations during exception handling. If an exception is thrown, the matching catch clause is executed and control passes to the finally block (if there is one).
finalize-method name. Java technology allows the use of the finalize() method to do necessary cleanup work before the garbage collector clears the object from memory. This method is called by the garbage collector on this object when it determines that the object is not referenced. It is defined in the Object class, so all classes inherit it. Subclasses override the finalize() method to organize system resources or perform other cleanup work. The finalize() method is called on this object before the garbage collector deletes the object.

55. How to handle hundreds of thousands of concurrent data?
Answer: Use stored procedure or transaction. When the maximum identifier is obtained, it is updated at the same time. Note that the primary key is not in the auto-increment mode. This method will not duplicate the primary key when used concurrently. To obtain the maximum identifier, a stored procedure is required.

56. Are there any major BUGs in Session, and what methods has Microsoft proposed to solve them?
Answer: Due to the process recycling mechanism in iis, the Session will be lost if the system is busy. You can use Sate server or SQL Server database to store the Session. However, this method is slower and cannot capture the END event of the Session.

57. What is the difference between process and thread?
Answer: The process is the unit of resource allocation and scheduling by the system; the thread is the unit of CPU scheduling and dispatch. A process can have multiple threads, and these threads share the resources of the process.

58. What is the difference between heap and stack?
Answer:
Stack: automatically allocated and released by the compiler. Variables defined within a function body are usually on the stack.
Heap: Generally allocated and released by the programmer. What is allocated using memory allocation functions such as new and malloc is on the heap.

59. What is the role of adding static before member variables and member functions?
Answer: They are called constant member variables and constant member functions, also known as class member variables and class member functions. Used to reflect the status of the class respectively. For example, class member variables can be used to count the number of class instances, and class member functions are responsible for such statistical actions.

60.ASP. NET compared with ASP, what are the main improvements?
Answer: asp interpreted form, aspx compiled form, improves performance and helps protect source code.

61. Generate an int array with a length of 100, and randomly insert 1-100 into it, and it cannot be repeated.
int[] intArr=new int[100];
ArrayList myList=new ArrayList();
Random rnd=new Random();
while(myList.Count<100)
{
int num=rnd.Next(1,101);
if(!myList.Contains(num))
myList.Add(num);
}
for(int i=0 ;i<100;i++)
intArr[i]=(int)myList[i];

62. Please explain several commonly used methods of passing parameters between pages in .net, and say Identify their strengths and weaknesses.
Answer: session(viewstate) is simple, but easy to lose
application global
cookie is simple, but may not be supported, and may be forged
input ttype="hidden" is simple, may be forged
The url parameters are simple, displayed in the address bar, and have limited length
The database is stable and safe, but the performance is relatively weak

63. Please indicate the meaning of GAC?
Answer: Global assemblyCache.

64. How many ways are there to send a request to the server?
Answer: get, post. Get is generally a link method, and post is generally a button method.

65.What is the difference between DataReader and Dataset?
Answer: One is a read-only cursor that can only move forward, and the other is a table in memory.

66. How many stages does the software development process generally have? What is the role of each stage?
Answer: Requirements analysis, ArchitectureDesign, code writing, QA, deployment

67. What is the meaning of the two keywords using and new in c#? Please write down your What does it mean to know? The using directive and statement new create an instance new hides methods in the base class.
Answer: using introduces a namespace or uses unmanaged resources
new creates a new instance or hides the parent class method

68. To process a string, first remove the spaces at the beginning and end of the string Remove, if there are consecutive spaces in the middle of the string, only one space is retained, that is, multiple spaces are allowed in the middle of the string, but the number of consecutive spaces cannot exceed one.
Answer: string inputStr=" xx xx ";
inputStr=Regex.Replace(inputStr.Trim()," *"," ");

69. What does the following code output? Why?
int i=5;
int j=5;
if (Object.ReferenceEquals(i,j))
Console.WriteLine("Equal");
else
Console .WriteLine("Not Equal");
Answer: Not equal, because the object is compared

70. What is SQL injection and how to prevent it? Please give an example.
Answer: Use sql keywords to attack the website. Filter keywords' etc.

71. What is reflection?
Answer: Dynamically obtain assembly information

72. How to write using SingletonDesign pattern
Answer: new in static attribute, constructor private

73 .What is Application Pool?
Answer: Web applications, similar to Thread Pool, improve concurrency performance.

74.What is a virtual function? What is an abstract function?
Answer: Virtual function: A function that is not implemented and can be inherited and rewritten by subclasses. Abstract function: A function that stipulates that its non-virtual subclass must be implemented and must be overridden.

75.What is XML?
Answer: XML is extensible markup language. eXtensible Markup Language. Marks refer to information symbols that computers can understand. Through such marks, computers can process articles containing various information. How to define these tags, you can choose an internationally accepted tag language, such as HTML, or you can use a tag language like XML that is freely decided by the relevant people. This is the extensibility of the language. XML is simplified and modified from SGML. It mainly uses XML, XSL and XPath, etc.

76.What is Web Service? UDDI?
Answer: Web Service is a network-based, distributed modular component that performs specific tasks and abides by specific technical specifications. These specifications enable Web Service to interact with other compatible components. Interoperability.
The purpose of UDDI is to establish standards for e-commerce; UDDI is a set of Web-based, distributed, information registration center implementation standards for Web Service, and also includes a set of implementation standards that enable enterprises to provide their own Web Service registration to enable other enterprises to discover the implementation standard of the access protocol.
 
77.What are user controls in ASP.net?
Answer: User controls are generally used when the content is mostly static, or may change slightly. The use is relatively large. It is similar to include in ASP. But the function is much more powerful.

78. List the XML technology and its applications that you know
Answer: xml is used for configuration and for saving static data types . The most exposed to XML is web services. .and config

79.What are the commonly used objects in ADO.net? Describe each.
Answer: Connection database connection object
Command database command
DataReader data reader
DataSet Data set

80. What is code-Behind technology.
Answer: Files with three suffixes of ASPX, RESX and CS, this is code separation. It realizes the separation of HTML code and server code. It facilitates code writing and organization.

81. What is SOAP and what are it? application.
Answer: simple object access protocol, simple object acceptance protocol. It uses xml as the basic coding structure and is built on existing communication protocols (such as http, but it is said that ms is working on the lowest architecture of soap on tcp/ip) A protocol that standardizes the use of Web Services..

82.The difference between property and attribute in C#, what are their uses, and what are the benefits of this mechanism?
Answer: One is an attribute, used to access fields of a class, and the other is a property, used to identify additional properties of classes, methods, etc.

83. The main difference between XML and HTML
Answer: 1. XML distinguishes between uppercase and lowercase letters, while HTML does not.
2. In HTML, you can omit closing tags such as

or if the context clearly shows where the paragraph or list key ends. In XML, the closing tag must not be omitted.
3. In XML, elements that have a single tag without a matching closing tag must end with a / character. This way the parser knows not to look for the closing tag.
4. In XML, attribute values ​​must be enclosed in quotation marks. In HTML, quotation marks are optional.
5. In HTML, you can have attribute names without values. In XML, all attributes must have corresponding values. What is the
ternary operation
symbol in 84.c#?
answer:? :.

85. When integer a is assigned to an object object, will integer a be?
Answer: Packing.

86. What are the _accessible forms of class members?
Answer: this.;new Class().Method;

87.public static const int A=1;Is there an error in this code? What is it?
Answer: const cannot be modified with static.

88.float f=-123.567F; int i=(int)f;The value of i is now_?
Answer: -123.

89. What is the keyword of delegate declaration?
Answer: delegate.

90. What are the characteristics of classes modified with sealed?
Answer: Sealed, cannot be inherited.

91. All custom user controls in Asp.net must inherit from?
Answer: Control.

92. In .Net all serializable classes are marked as_?
Answer: [serializable]

93. In .Net managed code we don’t have to worry about memory Vulnerability, is this because of it?
Answer: GC.

94. Are there any errors in the code below? _
using System;
class A
{
public virtual void F(){
Console.WriteLine("A.F");
}
}
abstract class B:A
{
public abstract override void F(); Answer: abstract override cannot be modified together.
} // new public abstract void F();
95. When the class When T declares only a private instance constructor, outside the program text of T, a new class can (can or cannot) be derived from T, and any instance of T cannot (can or cannot) be directly created.
Answer: No, no.

96. Is there any error in the following code?
switch (i){
case(): Answer: //case() condition cannot be empty
CaseZero();
break;
case 1:
CaseOne();
break;
case 2 :
dufault; Answer: //wrong, the format is incorrect
CaseTwo();
break;
}

97. In .Net, class System.Web.UI Can .Page be inherited?
Answer: Yes.

What is the error handling mechanism of 98..net?
Answer: The .net error handling mechanism adopts the try->catch->finally structure. When an error occurs, it is thrown up layer by layer until a matching Catch is found.

99. Is there any error in using operator declaration and only == is declared?
Answer: Do you want to modify Equale and GetHash() at the same time? If you overload "==", you must overload "! ="

100. How to user-defined messages in .net (C# or vb.net) and process these messages in the form.
Answer: Overload the DefWndProc function in the form to process the message:
protected override void DefWndProc ( ref System.WinForms.Message m )
{
switch(m.msg)
{
case WM_Lbutton:
///The usage of the Format function of string is different from that of CString in MFC
String message = string.Format("Message received! The parameters are: {0}, {1 }",m.wParam,m.lParam);
MessageBox.Show(message);///Display a message box
break;
case USER:
Processing Code
default:
base.DefWndProc(ref m);///Call the base class function to process non-custom messages.
break;
}
}

101. How to cancel the closing of a form in .net (C# or vb.net).
Answer: private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel=true;
}

102. In .net (C# or vb.net), what is the difference between Appplication.Exit or Form.Close?
Answer: One is to exit the entire application, and the other is to close one of the forms.

103. In C#, there is a double variable, such as 10321.5, such as 122235401.21644. As a currency value, how can it be output according to the habits of different countries. For example, the United States uses $10,321.50 and $122,235,401.22, while in the United Kingdom it is £10 321.50 and £122 235 401.22
Answer: System.Globalization.CultureInfo MyCulture = new System.Globalization.CultureInfo("en-US");
//System.Globalization.CultureInfo MyCulture = new System.Globalization.CultureInfo("en-GB"); is the British currency type
decimal y = 9999999999999999999999999999m;
string str = String.Format(MyCulture," My amount = {0:c}",y);

104. A certain password only uses a total of 5 letters K, L, M, N, and O. The words in the password are arranged from left to right. The password word must follow the following rules:
(1) The minimum length of the password word is two letters, which can be the same or different
(2) K cannot be the first letter of the word
(3 ) If L appears, it appears more than once
(4) M cannot be the last or penultimate letter
(5) K appears, then N must appear
(6) O If it is the last letter, L must appear
Question 1: Which of the following letters can be placed after O in LO to form a 3-letter password word?
A) K B)L C) M D) N
Answer: B

Question 2: If the letters that can be obtained are K, L, and M, then a two-letter password word that can be formed What is the total number?
A)1 B)3 C)6 D)9
Answer:A

Question 3: Which of the following is a word password?
A) KLLN B) LOML C) MLLO D)NMKO
Answer: C

8. 62-63=1 The equation does not hold, please move a number (minus signs and equals cannot be moved ), so that the equation holds, how to move?
Answer: 62 moved to the 6th power of 2

105. For such an enumeration type:
enum Color:byte
{
Red,
Green,
Blue,
orange
}
Answer: string[] ss=Enum.GetNames(typeof(Color));
byte[] bb=Enum.GetValues(typeof(Color)) ;

106. What is the difference between property and attribute in C#, what are their uses, and what are the benefits of this mechanism?
Answer: attribute: base class of custom attributes; property: attributes in the class

107. Can C# perform direct operations on memory?
Answer: Under .net, .net refers to the garbage collection (GC) function, which replaces the programmer. However, in C#, the Finalize method cannot be implemented directly, but in the destructor Call the Finalize() method of the base class

108.ADO. What are the main improvements of NET compared to ADO and so on?
Answer: 1: Ado.net does not rely on the ole db provider, but uses the program provided by .net hosting. 2: Does not use com3: No longer supports dynamic cursors and server-side games. 4: You can disconnect the connection. Keep the current data set available 5: Strong type conversion 6: XML support

109. Write an HTML page to implement the following functions. When you left-click the page, "Hello" is displayed, and when you right-click, "Right-click is prohibited" is displayed. . And automatically close the page after 2 minutes.
Answer:

110. Briefly describe ASP. NET server controlLife cycle
Answer: Initialize load view state handle postback data load send postback change notification handle postback event prerender save state render disposition unload

111. Can Anonymous Inner Class extend (inherit) other classes and implement interface (interface)?
Answer: No, you can implement interface

112.Static Nested Class and The more you say about the difference of Inner Class, the better.
Answer: Static Nested Class is an inner class declared as static, which can be instantiated without relying on external class instances. Usually inner classes need to be instantiated after the outer class is instantiated.

113., The difference between & and &&.
& is the bit operator, which means bitwise AND operation, && is the logical operator, which means logical AND (and).

114.The difference between HashMap and Hashtable.
Answer: HashMap is a lightweight implementation of Hashtable (non-thread-safe implementation). They both complete the Map interface. The main difference is that HashMap allows empty (null) key values ​​(key). Because It is not thread-safe and may be more efficient than Hashtable.

115.short s1 = 1; s1 = s1 + 1; What’s wrong? short s1 = 1; s1 += 1; What’s wrong?
Answer: short s1 = 1; s1 = s1 + 1; (The result of the s1+1 operation is int type, which requires forced conversion to the type)
short s1 = 1; s1 += 1; (can Compile correctly)

116. Can the Overloaded method change the type of the return value?
Answer: The Overloaded method can change the type of the return value.

117.What is the difference between error and exception?
Answer: error indicates a serious problem when recovery is not impossible but difficult. For example, memory overflow. It is impossible to expect a program to handle such a situation.
exception represents a design or implementation problem. That is, it represents a situation that would never occur if the program were running normally.

118. What is the difference between <%# %> and <% %>?
Answer: <%# %> indicates the bound data source
<% %> is a server-side code block

119. Do you think ASP.NET 2.0 (VS2005) and What's the biggest difference between the development tools you used before (.Net 1.0 or other)? Which development ideas (pattern/architecture) you used on the previous platform can be transplanted to ASP.NET 2.0 (or have been embedded in ASP.NET 2.0)
Answer: 1 ASP.NET 2.0 put some code Encapsulation and packaging are eliminated, so a lot of code is reduced compared to 1.0 for the same function.
2 Supports both code separation and page embedding of server-side code. In the previous 1.0 version, .NET prompt help was only available in separated code files and could not be used in separate code files. The page embeds the server-side code to get help tips.
3 When switching between the code and the design interface, 2.0 supports cursor positioning. I prefer this
4 When binding data, doing table paging, Update, Delete, and other operations All can be operated visually, which is convenient for beginners
5 More than 40 new controls have been added to ASP.NET, reducing the workload

120. What is the difference between overloading and overwriting?
Answer: 1. The overriding of methods is the relationship between subclasses and parent classes, which is a vertical relationship; the overloading of methods is the relationship between methods in the same class, which is a horizontal relationship
2. Overriding only A relationship can be generated by one method or only a pair of methods; method overloading is the relationship between multiple methods.
3. Overwriting requires the same parameter list; overloading requires different parameter lists.
4. In the overwriting relationship, the method body to be called is determined based on the type of the object (the storage space type corresponding to the object); in the overloading relationship, the method body is selected based on the actual parameter list and formal parameter list at the time of calling. .

121. Describe the implementation process of the indexer in C#. Can it only be indexed based on numbers?
Answer: No. Any type can be used.

122. In C#, string str = null and string str = " " Please try to use text or images to explain the difference.
Answer: null has no space reference;
" " is a string with a space of 0;

123. Analyze the following code and fill in the blanks
string strTmp = "abcdefgXXXX ";
int i= System.Text.Encoding.Default.GetBytes(strTmp).Length;
int j= strTmp.Length;
After the above code is executed, i= j=
answer :i=13.j=10

124. In the SQLSERVER server, there are two fields ID and LastUpdateDate in the given table table1. ID represents the updated transaction number, and LastUpdateDate represents the server time at the time of update. Please use a SQL statement to obtain the last updated transaction number
Answer: Select ID FROM table1 Where LastUpdateDate = (Select MAX(LastUpdateDate) FROM table1)

125. Analyze the following code.
public static void test(string ConnectString)

{

System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
conn.ConnectionString = ConnectString;
try

{
conn.Open();
…….
}
catch(Exception Ex)
{
MessageBox. Show(Ex.ToString());
}
finally
{

if (!conn.State.Equals(ConnectionState.Closed))
conn.Close();
}
}
Excuse me

1) Can the above code use the connection pool correctly?

Answer: Answer: If the incoming connectionString is exactly the same, the connection pool can be used correctly. But the exact same meaning means that the number of spaces in the hyphen is in exactly the same order.

2) Regarding the exception handling method used in the above code, can all exceptions in the test method be caught and displayed?

Answer: You can only catch exceptions in database connections. (In finally and catch, if there are other operations that may cause exceptions, you should also use try and catch. So in theory, not all exceptions will be caught. Capture. )

126. The company requires the development of a component that inherits the System.Windows.Forms.ListView class and requires the following special functions: when clicking on the column header of each column of the ListView, the value of each row of the clicked column can be Rearranges all rows in the view (sorting similar to a DataGrid). Based on your knowledge, please briefly talk about your ideas:
Answer: According to the clicked column header, extract the ID of the column, sort according to the ID, and bind it to the ListView

127.What is WSE? What is the latest version?
Answer: WSE (Web Service Extension) package provides the latest WEB service security guarantee. The latest version is 2.0.

128. In the following example
using System;
class A
{
public A(){
PrintFields();
}
public virtual void PrintFields(){}
}
class B:A
{
int x=1;
int y;
public B(){
y= -1;
}
public override void PrintFields(){
Console.WriteLine("x={0},y={1}",x,y);
}


The above is the detailed content of ASP.NET interview questions collection. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn