1. In the following code, how do I reference the great in the namespace fabulous?
Namespace fabulous {// code in fabulous namespace}
Namespace super {namespace smashing {// great name defined }}
A: super. smashing. great
2. Is the string variable "supercalifragilisticexpialidocious" too long? Why?
A: No. in C #, there is no limit on the length of the string.
3. Overview of reflection and serialization?
A: Reflection provides encapsulated assembly, module, and type object. You can use reflection to dynamically create type instances and bind types to existing objects, you can also obtain the type from the existing object type and then call the method or access field and attribute of the type.
Serialization: the process of converting an object to a format transmitted by another media. For example, to serialize an object, Use Http to pass the object between the client and server over the internet, and use deserialization on the other end to obtain the object from the stream.
4. What is the delegate in C? Is an event a delegate?
A: delegate is a safe way, similar to function pointer, but it is much safer than pointer. It can pass a method as a parameter to another method, it can be understood as a reference to a function. An event is a message mechanism, which is a delegate without a method body.
5. Can I use the index generator in C # To implement a digital index only?
A: No. It can be of any type.
6. What are the differences between classes and structures in. NET?
A: The structure and class have similar syntaxes, but the structure is limited by more than the class. The structure cannot declare that there is a default constructor. The replicas of the structure are created and destroyed by the compiler. Therefore, the default constructor and destructor are not required. The structure is a value type, so changes made to the structure variables will not affect their original values, while the class is an application type. Changing the value of the variable will change its original value. The declarative structure uses the Struck keyword, the declarative class uses the class keyword, and the structure passed to the method is passed through the value instead of the reference. Unlike classes, the New Keyword can be used for Schema Instantiation. Class.
7. If two integers are stored in the var1 and var2 variables, what Boolean test can be used to check whether one of them is greater than 10?
A: (var1> 10) ^ (var2> 10 ).
8. What are the meanings of using and new keywords in c?
A: using introduces namespaces or uses unmanaged resources.
New creates an instance or hides the parent class method.
9. What is the difference between const and readonly?
A: The const keyword is used to declare the compile time.
Readonly is used to declare the runtime volume.
10. What are the differences between System. String and System. StringBuilder?
A: System. String is an unchangeable String. System. StringBuilder stores a variable string and provides some methods to modify the string.
11. How can the new Keyword be used in C?
A: in C #, The new Keyword can be used as an operator or modifier. It is used as an operator to create objects on the stack and call constructors. Used as a modifier to hide the inherited members of a base class member.
12. What is the role of the sealed keyword? In what situations do I need to use the sealed keyword?
A: The sealed modifier is mainly used to prevent unintentional derivation, but it can also promote some runtime optimization. Specifically, because the sealed class will never have any derived class, the call to the virtual function Member of the sealed class instance can be converted to a non-virtual call for processing.
13. In C #, which keywords can be used for version control?
A: both the override keyword and the new Keyword can be used for version control.
In C #, the method is not virtual by default. To make a method a virtual method, you must use the virtual modifier in the method declaration of the base class. Then, the derived class can use the override keyword to override the Virtual Methods in the base class, or use the new keyword to hide the Virtual Methods in the base class. If the override keyword and new Keyword are not specified, the compiler will issue a warning and the methods in the derived class will hide the methods in the base class.
14. Write the execution results of the following statements respectively.
(1) Console. WriteLine ("{0} -- {0: p} good", 12.34F );
(2) Console. WriteLine ("{0} -- {0: ####} good", 0 );
(3) Console. WriteLine ("{0} -- {0: 00000} good", 456 );
A: The execution results are as follows:
(1) 12.34 -- 1,234.00% good
(2) 0 -- good
(3) 456 -- 00456 good
15. What are the characteristics of the array type in C?
A: The array type in C # has the following features:
(1) arrays are generally used to store data of the same type, including the Object type.
(2) array is a reference type, not a value type.
(3) in C #, in addition to a one-dimensional array and multi-dimensional array, there are also staggered arrays.
16. What are the differences between errors and exceptions? Why are exceptions handled? What are the statements used for exception handling?
A: an error occurs when the code is executed. It interrupts or interferes with the normal process of the code and creates an exception object. When an error is interrupted, the program will try to find an exception handler (a piece of code that tells the program how to respond to the error) to help the program recover the process. In other words, an error is an event, and an exception is the object created by the event.
When the phrase "generate exception" is used, it indicates that an error occurs in the problematic method, and an exception object (including the error information and the time and location of the error) is created to respond to the error. Factors that cause errors and subsequent exceptions include user errors, resource failures, and programming logic failures. These errors are related to how the code implements a specific task, but not the purpose of the task.
If no exception processing is performed, that is, no response is made to the error, the robustness of the program will be greatly reduced, and even the normal operation cannot be ensured. Therefore, exception processing must be performed.
The statements used for exception handling include try-catch statements, try-catch-finally statements, and throw statements.
17. What is the conversion principle between different integer types in C?
A: During Integer Conversion, small-range types can be implicitly converted to large-range types, but Explicit conversions are required when large-range types are converted to small-range types.
18. Briefly describe the packing and unpacking process.
A: boxing is an interface type that implicitly converts the value type to the object type or converts the value type to the object type. If a value is packed, an object instance is allocated and the value is copied to the new object. The binning operation explicitly converts the object type to the value type or the interface type implemented by the value type to the value type.
19. What is a namespace? What is the relationship between namespaces and class libraries?
A: A namespace is a logical grouping of classes. It divides classes into different namespaces based on certain links or links.
The namespace can also contain other namespaces, such as System. Windows. Forms, which means that the System namespace has a Windows namespace and the Windows namespace has a Forms namespace.
20. What types of applications can I use C # To compile?
A: Console applications, Windows applications, crystal report applications, and ASP. NET Web application, ASP. NET Web service application, ASP. NET Crystal Reports Web applications and smart device applications.