[. Net (C #)]
How to copy an array to arraylist
(1) string [] S = {"111", "22222 "};
Arraylist list = new arraylist ();
List. addrange (s );
(2) string [] S = {"111", "22222 "};
Arraylist list = new arraylist (s );
[. Net (C #)]
Lists sharing classes and database-specific classes in ADO. net.
Shared class
Dataset
Datatable
Datarow
Datacolumn
Datarelation
Constraint
Datacolumnmapping
Datatablemapping
Specific Class
(X) Connection
(X) command
(X) commandbuilder
(X) dataadapter
(X) datareader
(X) parameter
(X) Transaction
[. Net (C #)]
After executing the following code:
String strtemp = "abcdefg ";
Int I = system. Text. encoding. Default. getbytes (strtemp). length;
Int J = strtemp. length;
Q: I =? J =?
I = (14); j = (11) Two Chinese bytes
[. Net (C #)]
The rule for a column is as follows: 1, 1, 2, 3, 5, 8, 13, 21, 34 ...... calculate the number of digits 30th, and implement it using 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 );
}
}
[. Net (C #)]
Differences between override and overload
A: Reload indicates 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.
[. Net (C #)]
Traverse all textbox controls on the page and assign it a string. Empty?
Foreach (system. Windows. Forms. 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;
}
}
[. Net (C #)]
How can I program a bubble sort algorithm?
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;
}
}
}
[. Net (C #)]
Evaluate the values of the following expressions and write out one or more implementation methods: 1-2 + 3-4 + ...... + M
A:
Int num = int. parse (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 ();
[. Net (C #)]
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
[. Net (C #)]
Based on the knowledge of thread security, analyze the following code. Will a deadlock occur when I> 10 is used to call the test method? And briefly explain the reasons.
Public void test (int I)
{
Lock (this)
{
If (I> 10)
{
I --;
Test (I );
}
}
}
A: No deadlock will occur: int is passed by value, so each change is only a copy, so no deadlock will occur.
But if you replace int with an object, the deadlock will occur.
[. Net (C #)]
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 ).
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 );
}
}
[. Net (C #)]
You can use foreach to traverse the accessed object. You need to implement the ___ interface or declare the ___ method type.
A: ienumerable and getenumerator.
[. Net (C #)]
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.
[. Net (C #)]
The two pairs have the same image value (X. Equals (y) = true), but different hash codes are available. Is this true?
A: No. It has the same hash code.
[. Net (C #)]
Can swtich work on byte, long, and string?
A: In switch (expr1), expr1 is an integer expression.
Therefore, the parameters passed to the switch and case statements should be int, short, Char, or byte.
Long and string cannot apply to swtich.
[. Net (C #)]
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.
[. Net (C #)]
Does list, set, and map inherit from the collection interface?
A: List, set is. map is not
[. Net (C #)]
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 object.
Equals () is overwritten in the class to return the true value when the content and type of the two separated objects match.
[. Net (C #)]
Does the array have the length () method? Does string have the length () method?
A: The array does not have the length () method. It has the Length attribute. String has the length () method.
[. Net (C #)]
What is the difference between sleep () and wait?
A: The sleep () method is used to stop a thread for a period of time.
After the sleep interval expires, the thread may not resume execution immediately.
This is because at that time, other threads may be running and not scheduled to give up execution.
Unless (a) the "Awake" thread has a higher priority (B) the running thread is blocked for other reasons.
When wait () is a thread interaction, if the thread sends a wait () call to a synchronous pair like x
This thread will pause the execution, And the called image enters the waiting state until it is awakened or the waiting time reaches.
[. Net (C #)]
Short S1 = 1; S1 = S1 + 1; what is the error? Short S1 = 1; S1 + = 1; what is the error?
Answer: Short S1 = 1; S1 = S1 + 1;
Error: S1 is short type, S1 + 1 is int type, and cannot be converted to short type explicitly.
It can be changed to S1 = (short) (S1 + 1 ). Short S1 = 1; S1 + = 1 is correct.
[. Net (C #)]
How to handle hundreds of thousands of concurrent data records?
A: use stored procedures or transactions. Update at the same time when getting the maximum ID ..
Note that the primary key is not self-incremental. When this method is concurrent, there will be no duplicate primary keys ..
A stored procedure is required to obtain the maximum identity.
[. Net (C #)]
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 sessions. However, this method is slow,
The end event of the session cannot be captured.
[. Net (C #)]
ASP. Net compared with ASP, what are the main advances?
A: ASP interpretation form and aspx compilation form help improve the performance and protect the source code.
[. Net (C #)]
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];
[. Net (C #)]
What does GAC mean?
A: Global Assembly cache.
[. Net (C #)]
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.
[. Net (C #)]
What is the difference between datareader and dataset?
A: One is a read-only cursor and the other is a table in memory.
[. Net (C #)]
How many stages are involved in the software development process? What is the role of each stage?
Answer: requirement analysis, architecture design, code writing, QA, and deployment
[. Net (C #)]
To process a string, remove the spaces at the beginning and end of the string.
If the string contains consecutive spaces, only one space is reserved. That is, multiple spaces are allowed in the string.
However, the number of consecutive spaces cannot exceed one.
A: String inputstr = "xx ";
Inputstr = RegEx. Replace (inputstr. Trim (),"*","");
[. Net (C #)]
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.
[. Net (C #)]
What is SQL injection and how to prevent it? For example.
A: attackers use SQL keywords to attack websites. Filter keywords, etc.
[. Net (C #)]
What is reflection?
A: Dynamically Retrieve assembly information
[. Net (C #)]
What is application pool?
A: Web applications, similar to thread pools, improve concurrency performance.
[. Net (C #)]
What is a virtual function? What is a pumping function?
A: virtual functions: functions that are not implemented can be inherited and overwritten by sub-classes.
Image pulling function: specifies the functions that must be implemented by non-virtual subclass and must be overwritten.
[. Net (C #)]
What is a user control in Asp.net?
A: The user control is generally used when the content is mostly static or slightly changed ..
It is relatively large in use. It is similar to include... in ASP, but the function is much more powerful.
[. Net (C #)]
List the XML technologies you know and their applications.
A: XML is used for configuration. It is used to save static data types. Web Services... And config are the most exposed to XML.
[. Net (C #)]
What are the common objects in ado.net? Describe them separately.
Connection database connection to a dataset similar to the Command database command datareader data reader Dataset
[. Net (C #)]
When integer a is assigned to an object, integer a is boxed.
[. Net (C #)]
Public static const int A = 1; is this Code incorrect? What is it?
A: The const cannot be modified using static.
88. Float F =-123.567f; int I = (INT) F; The I value is ___-123.
[. Net (C #)]
The keyword of the delegate statement is ___: Delegate.
[. Net (C #)]
All Custom User Controls in Asp.net must inherit from ___: control.
[. Net (C #)]
All serializable classes in. NET are marked as __: [serializable]
[. Net (C #)]
In. Net hosting code, we don't have to worry about memory vulnerabilities, because GC is available.
[. Net (C #)]
Are there any errors in the following code? _______
Using system;
Class
{
Public Virtual void F (){
Console. writeline ("a.f ");
}
}
Abstract class B:
{
Public abstract override void F (); A: Abstract override cannot be modified together.
} // New public abstract void F ();
[. Net (C #)]
When class t only declares the private instance Constructor
You cannot derive a new class from T outside the program text of T, and you cannot directly create any instance of T.
[. Net (C #)]
In. net, the class system. Web. UI. page can be inherited.
[. Net (C #)]
Operator is used to declare and only declare =. Is there any error?
A: Do you want to modify equale and gethash () at the same time ()? If "=" is reloaded, it must be reloaded "! ="
[. Net (C #)]
A password only uses five letters (K, L, M, N, and O). The words in the password are arranged from left to right. The password words must follow the following rules:
(1) the minimum length of a password word is two letters, which can be the same or different.
(2) K cannot be the first letter of a word.
(3) If l appears, more than once
(4) M cannot make the last or second-to-last letter
(5) If K appears, N must appear.
(6) If O is the last letter, l must appear
Question 1: Which of the following letters can be placed behind o in Lo to form a three-letter password word?
A) k B) l c) m d) n answer: B
Question 2: If the letters K, L, and m can be obtained, what is the total number of two letter-length password words?
A) 1 B) 3 C) 6 d) 9 Answers:
Question 3: Which of the following is the word password?
A) klln B) loml c) mllo d) nmko answer: c
[. Net (C #)]
62-63 = 1 the equation is not true. Please move a number (the minus sign and the equal sign cannot be moved) so that the equation is true. How can we move it?
Answer: 62 is moved to the power 6 of 2.
[. Net (C #)]
For such an enumeration type:
Enum color: byte
{
Red,
Green,
Blue,
Orange
}
A: String [] Ss = enum. getnames (typeof (color ));
Byte [] BB = enum. getvalues (typeof (color ));
[. Net (C #)]
Write an HTML page to implement the following functions: "Hello" is displayed when you click the page"
Right-click is displayed, "prohibit right-click ". The page is automatically closed in 2 minutes.
A: <script language = JavaScript>
SetTimeout ('window. Close (); ', 3000 );
Function show ()
{
If (window. event. Button = 1)
{
Alert ("Left ");
}
Else if (window. event. Button = 2)
{
Alert ("right ");
}
} </SCRIPT>
[. Net (C #)]
Briefly describe the lifecycle of ASP. NET Server controls
A: Initialize the loading view status. process the returned data. Load the returned data. Send a change notification.
Processing and sending back events pre-rendering and saving status rendering processing and uninstalling
[. Net (C #)]
. Anonymous inner class (anonymous internal class) can extends (inherit) other classes?
Can implements (implemented) interface (Interface) be implemented )?
A: No. The interface can be implemented.
[. Net (C #)]
& Is a bitwise operator that represents bitwise and operation, & is a logical operator that represents logic and (and ).
[. Net (C #)]
The difference between. hashmap and hashtable.
A: hashmap is a lightweight Implementation of hashtable (non-thread-safe implementation). They have completed the map interface,
The main difference is that hashmap allows null key values. Because of non-thread security, the efficiency may be higher than hashtable.
[. Net (C #)]
Can the. overloaded method change the type of the returned value?
A: The overloaded method can change the type of the returned value.
[. Net (C #)]
<% # %> Indicates the bound data source.
<%> Is a server-side code block.
[. Net (C #)]
. What is the biggest difference between ASP. NET 2.0 (vs2005) and your previous development tool (. NET 1.0 or other?
Which development ideas (pattern/architecture) did you use on the previous platform)
It can be transplanted to ASP. NET 2.0 (or has been embedded in ASP. NET 2.0)
Answer: 1 ASP. NET 2.0 encapsulates and packages some code, so it reduces a lot of code compared to the same function of 1.0.
2. Code separation and page embedding are supported at the same time.
In earlier versions 1.0,. net prompts that only the code files are separated.
The server code cannot be embedded on the page for help,
3. During code and design interface switching, 2.0 supports cursor positioning.
4. When binding data, you can perform operations such as paging, update, and delete on tables in a visualized manner, facilitating beginners.
5. More than 40 new controls are added to ASP. NET, reducing the workload.
[. Net (C #)]
What is the difference between overload and overwrite?
Answer: 1. The method overwrites the relationship between the Child class and the parent class, and is a vertical relationship;
Method overloading refers to the relationship between methods in the same class and horizontal relationship.
2. Override can only be composed of one method, or can only be composed of one method. Method Overloading is the relationship between multiple methods.
3. The overwrite request parameter list is the same; the reload request parameter list is different.
4. In the overwriting relationship, the method body called is determined based on the object type (corresponding to the bucket type of the object;
The overload relationship is used to select the method body based on the real parameter table and the form parameter table during the call.
[. Net (C #)]
What is WSE? What is the latest version?
A: The WSE (Web Service Extension) package provides the latest web service security assurance. The latest version is 2.0.
[. Net (C #)]
. In the following example
Using system;
Class
{
Public static int X;
Static (){
X = B .y + 1;
}
}
Class B
{
Public static int y = a.x + 1;
Static B (){}
Static void main (){
Console. writeline ("x = {0}, y = {1}", a.x, B .y );
}
}
What is the output result? Answer: x = 1, y = 2
[. Net (C #)]
. How to copy an array to the arraylist
Foreach (Object o in array)
Arraylist. Add (O );
[. Net (C #)]
. DataGrid. What data sources can datasouse connect to? [dataset, datatable, dataview]
Dataset, datatable, dataview, ilist
[. Net (C #)]
. Overview of reflection and serialization
Reflection: The Assembly contains modules, while the module contains types and types, including Members.
Reflection provides encapsulated assembly, module, and type objects.
You can use reflection to dynamically create instances of the type, bind the type to an existing object, or obtain the type from an existing object.
Then, you can call a method of the type or access its fields and attributes.
Serialization: serialization is the process of converting an object into a format that is easy to transmit.
For example, you can serialize an object and Use http to transmit the object between the client and the server over the Internet.
At the other end, deserialization reconstructs the object from the stream.
[. Net (C #)]
How to Understand delegation?
A: It is said to be equivalent to a function pointer. If a delegate is defined, the method can be called without calling the original method name.
Msdn2005 explains this as follows:
Delegation has the following features:
The delegate is similar to a C ++ function pointer, but it is type-safe.
The delegate allows passing methods as parameters.
A delegate can be used to define a callback method.
The delegate can be linked together. For example, multiple methods can be called for an event.
The method does not need to be exactly matched with the delegate signature. For more information, see covariant and inverter.
C #2.0 introduces the concept of anonymous methods, which allow passing code blocks as parameters instead of Individually Defined methods.
[. Net (C #)]
. What is code-behind technology.
A: code separation is wise. It is uncomfortable to mix it into a pile like ASP.
You can also understand that the HTML code is written at the front end, and the C # code is written at the back end.
Of course, there are also scripts and class calls at the front end, which can also be written together.
[. Net (C #)]
What is the name of the implicit parameter for the set method that passes in an attribute?
Value. Its type is the same as that of its attribute.
[. Net (C #)]
Where can I access the property/method modified by protected?
It can be accessed in the subclass that inherits or indirectly inherits from this class.
[. Net (C #)]
Will private members be inherited?
Yes, but cannot be accessed. So it seems that they cannot be inherited, but they are actually inherited.
[. Net (C #)]
Describe the modifier protected internal.
In the same assembly, his access level is the same as that in public, while in cross-assembly access, his access level is the same as protected.
That is, the range of protected + the range of internal.
[. Net (C #)]
C # provides a default non-parameter constructor. When I implement another constructor with a parameter
You also want to keep this non-parameter constructor. How many constructors should I write?
Two. Once you implement a constructor, C # will no longer provide the default constructor.
Therefore, you need to manually implement the non-parameter constructor.
[. Net (C #)]
What does virtual mean in method definition?
The virtual method can be overwritten by the quilt class.
[. Net (C #)]
Can I override non-static methods into static methods?
No. The signature of the overwriting method must be consistent with that of the overwriting method, except for changing virtual to override.
[. Net (C #)]
Can I override a private virtual method?
No, or even the sub-classes cannot access the private methods in the parent class.
[. Net (C #)]
Can a class be prevented from being inherited by other classes?
Yes. Use the keyword sealed.
[. Net (C #)]
Can a class be inherited, but cannot a method be overwritten?
Yes. Mark this class as public and the method as sealed.
[. Net (C #)]
What is abstract class )?
A class that cannot be instantiated. Abstract classes generally contain abstract methods. Of course, they can also be implemented.
An inherited class can be instantiated only when abstract methods of all abstract classes are implemented.
[. Net (C #)]
When must a class be declared as an abstract class?
When this class contains abstract methods, or the class does not fully implement the abstract methods of the parent class.
[. Net (C #)]
Why cannot I specify a modifier for a method in an interface?
The methods in the interface are used to define the contract for communication between objects. It is meaningless to specify the methods in the interface as private or protected.
They are public methods by default.
[. Net (C #)]
Can I inherit multiple interfaces?
Of course.
[. Net (C #)]
What if there are repeated method names in these interfaces?
In this case, you can decide how to implement it. Of course, you must be very careful.
However, there is no problem in the compilation process.
[. Net (C #)]
What is the difference between an interface and an abstract class?
All methods in the interface must be abstract and the access modifier of the method cannot be specified.
Abstract classes can be implemented by methods, or you can specify the access modifier of methods.