C # highlights of interview questions

Source: Internet
Author: User

2. List several methods for passing values between ASP. NET pages.
A. 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. 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. To describe the implementation process of the indexer in C #, can it be indexed only by numbers?
A: No. Any type can be used.

10. Evaluate the values of the following expressions and write out one or more implementation methods: 1-2 + 3-4 + ...... + M
A:
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 ();

12. In the following example
Using System;
Class
{
Public ()
{
PrintFields ();
}
Public virtual void PrintFields (){}
}
Class B:
{
Int x = 1;
Int y;
Public B ()
{
Y =-1;
}
Public override void PrintFields ()
{
Console. WriteLine ("x = {0}, y = {1}", x, y );
}
What is the output when new B () is used to create B's instance?
Answer: X = 1, Y = 0; x = 1 y =-1

13. What is an application domain?
A: The application domain can be considered as a lightweight process. Security. Small resource occupation.

14. What are the explanations of CTS, CLS, and CLR?
A: CTS: a general-purpose language system. CLS: general language specification. CLR: Common Language Runtime Library.

15. What is packing and unpacking?
A: From the value type interface to the Reference Type Packing. Converts a reference type to a value type Unbox.

16. What is regulated code?
A: unsafe: unmanaged code. Does not run through CLR.

17. What is a strong system?
A: RTTI: The type recognition system.

 
Reply
 
R & D center _
One Fan
2nd floor

Which classes are required for reading and writing databases in 18.net? What are their roles?
Answer: DataSet: data storage.
DataCommand: Execute the statement command.
DataAdapter: a collection of data.

21. In. net, what does the accessory mean?
A: assembly. (Intermediate language, source data, resources, assembly list)

22. What are common WebService call methods?
A: 1.use the wsdl.exe command line tool.
2. Use the Add web reference menu option in vs. net

What is the working principle of 23..net remoting?
A: the server sends a process number and a program domain number to the client to determine the object location.

29. Based on the knowledge of thread security, analyze the following code. Will the deadlock occur when I> 10 is called when the test method is called? And briefly explain the reasons.
Public void test (int I)
{
Lock (this)
{
If (I> 10)
{
I --;
Test (I );
}
}
}
A: No deadlock will occur (but one int is passed by value, so each change is only a copy, so no deadlock will occur. However, if you replace int

Object, then the deadlock will occur)

30. Briefly discuss your understanding of the remoting and WebService technologies under the Microsoft. NET architecture and their practical applications.
A: WS uses HTTP to penetrate the firewall. Remoting can improve the efficiency by using TCP/IP and binary transmission.

Remoting is used in. net to span machine, process, and appdomain

For a three-component program, the remoting technology can be used to construct the method calling technology. It is the basic technology of distributed applications. It is equivalent to the previous DCOM

Web Service is a common model for building applications and can be implemented on all operating systems that support internet communication. Web

Service enables the combination of component-based development and web to achieve the best, component-based object model

31. The company requires the development of a component that inherits the system. Windows. Forms. listview class and requires the following special features:

Click the values of each row in the column to rearrange all rows in the view (the sorting method is similar to that of the DataGrid ). Based on your knowledge, please briefly discuss your ideas
A: Based on the column header that you click, the ID of this column is taken out, sorted by this ID, and bound to listview.

32. Specify the following XML file to complete the algorithm flow chart.
<Filesystem>
<Driverc>
<Dir dirname = "msdos622">
<File filename = "command.com"> </File>
</Dir>
<File filename = "msdos. sys"> </File>
<File filename = "Io. sys"> </File>
</Driverc>
</Filesystem>
Draw a flowchart that traverses all file names (filename) (use recursive algorithms ).
A:
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 );
}
}

35. To use foreach to traverse the accessed object, you need to implement the ____________ interface or the type of the declared ________________ method.
A: IEnumerable and GetEnumerator.

36. What is GC? Why does GC exist?
A: GC is a garbage collector. Programmers do not have to worry about memory management, because the Garbage Collector will automatically 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 are created?
A: There are two objects, one being "xyx" and the other being the reference object s pointing to "xyx.

38. What is the difference between abstract class and interface?
A:
The class that declares the existence of a method without implementing it is called abstract class. It is used to create a class that reflects some basic behaviors and declare a method for this class.

But cannot implement this class in this class. You cannot create an abstract instance. However, you can create a variable whose type is an image class and point it to a specific

An instance of the subclass. There cannot be a pumping constructor or a pumping static method. The subclasses of abstract classes provide implementation for all the image extraction methods in their parent classes. Otherwise, they are

The image class is. Instead, implement this method in the subclass. Other classes that know their behavior can implement these methods in the class.

 
Reply
 
R & D center _
One Fan
Third floor

An interface is a variant of the image class. In the interface, all methods are extracted. Multi-inheritance can be achieved by implementing such an interface. All methods in the interface

They are all pumping images, and none of them have a program. The interface can only define static final member variables. The implementation of an interface is similar to that of a subclass, except that the implementation class cannot be defined by the interface.

Inheritance behavior. When a class implements a special interface, it defines (to be given by the program body) all the methods of this interface. Then, it can

Method of calling the interface. Because of the image class, it allows the interface name to be used as the type of the referenced variable. Normally, dynamic Association editing will take effect. The reference can be converted to the interface type or from

The instanceof operator can be used to determine whether the class of an object implements an interface.

39. Do I use run () or start () to start a thread ()?
A: To start a thread is to call the START () method so that the virtual processor represented by the thread is runable, which means it can be scheduled and executed by JVM. This does not mean

The thread will run immediately. The run () method can generate the exit sign to stop a thread.

40. Can an interface inherit the interface? Can the image extraction class implement the (implements) interface? Can the image class inherit the concrete class )?
A: The interface can inherit the interface. The image extraction class can implement the implements interface to determine whether the image extraction class can inherit the object class, provided that the object class must have a clear constructor.

41. Can Constructor be overwritten?
A: Constructor cannot be inherited, so Overriding cannot be overwritten, but Overloading can be overloaded.

42. Can I inherit the String class?
A: The String class is a final class, so it cannot be inherited.

44. The two pairs have the same image value (x. equals (y) = true), but different hash codes are available, right?
A: No. It has the same hash code.

45. Does swtich work on byte, long, and String?
A: In switch (expr1), expr1 is an integer, character, or string. Therefore, expr1 can be applied to byte and long, or string.

47. After a thread enters a synchronized method of an object, can other threads access other methods of this object?
No. One synchronized Method of an object can only be accessed by one thread.

48. can abstract methods be both static, native, and synchronized?
A: No.

49. Does List, Set, and Map inherit from the Collection interface?
A: List, Set is Map, not

50. The elements in the Set cannot be repeated. How can we identify whether the elements are repeated or not? Is = or equals () used ()? What are their differences?
A: The elements in the Set cannot be repeated. Use the iterator () method to identify whether the elements are repeated or not. Equals () is used to determine whether two sets are equal.
The equals () and = Methods Determine whether the reference value points to the same pair like equals () is overwritten in the class, so that when the content and type of the two separated objects match, the true value is returned.

.

51. Does the array have the length () method? Does String have the length () method?
A: neither the array nor the string has the Length () method, but only the Length attribute.

52. What is the difference between sleep () and wait?
A: The sleep () method suspends the current thread for a specified time.
Wait () releases the lock on the object and blocks the current thread until it acquires the lock again.

53. short s1 = 1; s1 = s1 + 1; what is the error? Short s1 = 1; s1 + = 1; what is the error?
Answer: There is a mistake in short s1 = 1; s1 = s1 + 1; s1 is short type, s1 + 1 is int type, and cannot be explicitly converted to short type. It can be changed to s1 = (short) (s1 + 1 ).

Short s1 = 1; s1 + = 1 is correct.

54. Let's talk about the differences between final, finally and finalize.
A:
Final-modifier (keyword) If a class is declared as final, it means that it cannot generate a new subclass and cannot be inherited as a parent class. Therefore, a class cannot

Declared as abstract, and declared as final. Declare variables or methods as final to ensure that they are not changed during use. Variable declared as final

The initial value must be specified during declaration, but can only be read in future references and cannot be modified. Methods declared as final can only be used and cannot be reloaded.
Finally-The Finally block is provided for troubleshooting. If an exception is thrown, the matched catch clause is executed and then controlled.

It will enter the Finally block (if any ).

 
Reply
 
R & D center _
One Fan
4th floor

Finalize-method name. Java technology allows the use of the finalize () method to perform necessary cleanup before the Garbage Collector clears the image from the memory. This method

It is called by the garbage collector when it determines that this object is not referenced. It is defined in the object class, so all classes inherit it. Subclass override

Use the finalize () method to sort system resources or perform other cleanup tasks. The finalize () method is called before the Garbage Collector deletes an object.

55. How to handle hundreds of thousands of concurrent data records?
A: use stored procedures or transactions. When getting the maximum ID, update it at the same time. Note that when the primary key is not in auto increment mode, this method will not have duplicate primary keys.

The big logo must have a stored procedure for obtaining.

56. What are the major bugs in session? What methods does Microsoft propose to solve them?
A: The session is lost when the system is busy due to the process recycle mechanism in IIS. You can use sate server or SQL Server database to store the session.

And cannot capture the end event of the session.

57. What is the difference between a process and a thread?
A: A process is the unit of resource allocation and scheduling by the system. A thread is the unit of CPU scheduling and scheduling. A process can have multiple threads which share the resources of the process.

Source.

58. What is the difference between stack and stack?
A: Stack is the memory space allocated during compilation. Therefore, you must define the size of the stack in your code. Stack is the memory space dynamically allocated during program running. You

You can determine the heap memory size to be allocated based on the program running status.

59. What is the role of adding static before member variables and member functions?
A: They are called common member variables and common member functions, also known as class member variables and class member functions. They are used to reflect the status of the class respectively. For example, class member variables can be used for statistics.

The number of class instances. The class member function is responsible for this statistical action.

60. ASP. NET compared with ASP, what are the main advances?
A: asp interpretation, aspx compilation, and performance improvement can be separated from the work of the artist, which is more conducive to team development.

61. generate an int array with a length of 100 and insert 1-100 randomly into it, which 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 describe several common methods for passing parameters between pages in. net and describe their advantages and disadvantages.
A: session (viewstate) is simple but easy to lose.
Application global
Cookies are simple but may not be supported and may be forged.
Input ttype = "hidden" is simple and may be forged
The url parameter is simple and displayed in the address bar with a limited length.
The database is stable and secure, but its performance is relatively weak.

63. What does GAC mean?
A: Global Assembly cache.

64. How many requests can be sent to the server?
A: get and post. Get is generally the link mode, and post is generally the button mode.

65. What is the difference between DataReader and Dataset?
A: One is a read-only cursor and the other is a table in memory.

66. How many stages are there in the software development process? What is the role of each stage?
Answer: requirement analysis, architecture design, code writing, QA, and deployment

67. What are the meanings of using and new keywords in c? Using command and statement new create instance new hide methods in the base class.
A: using introduces namespaces or uses unmanaged resources.
New create an instance or hide the parent class Method

68. to process a string, remove the spaces at the beginning and end of the string. If there are consecutive spaces in the string, only one space is reserved, that is, the characters are allowed.

The string contains multiple spaces, but the number of consecutive spaces cannot exceed one.
A: string inputStr = "xx ";
InputStr = Regex. Replace (inputStr. Trim (),"*","");

69. What is the output of the following code? Why?
Int I = 5;
Int j = 5;
If (Object. ReferenceEquals (I, j ))
Console. WriteLine ("Equal ");
Else
Console. WriteLine ("Not Equal ");
A: They are not equal, because they compare objects.

70. What is SQL injection and how to prevent it? For example.
A: Use the SQL language vulnerability to obtain a valid identity to log on to the system. For example, the identity verification program is designed as follows:
SqlCommand com = new SqlCommand ("Select * from users where username = '" + t_name.text + "' and pwd = '" + t_pwd.text + "'");
Object obj = com. ExcuteScale ();
If (obj! = Null)
{
// Pass Verification
}
This code is vulnerable to SQL injection. If you enter 1 'and 1 = '1 in t_pwd in t_name, you can enter the system.
 

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.