欢迎大家来到IT世界,在知识的湖畔探索吧!
- What’s the advantage of using System.Text.StringBuilder over System.String? StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it’s being operated on, a new instance is created.
- Can you store multiple data types in System.Array? No.
- What’s the difference between the System.Array.CopyTo() and System.Array.Clone()? The first one performs a deep copy of the array, the second one is shallow.
- How can you sort the elements of the array in descending order? By calling Sort() and then Reverse() methods.
- What’s the .NET datatype that allows the retrieval of data by a unique key? HashTable.
- What’s class SortedList underneath? A sorted HashTable.
- Will finally block get executed if the exception had not occurred? Yes.
- What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception? A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.
- Can multiple catch blocks be executed? No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.
- Why is it a bad idea to throw your own exceptions? Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project.
- What’s a delegate? A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.
- What’s a multicast delegate? It’s a delegate that points to and eventually fires off several methods.
- How’s the DLL Hell problem solved in .NET? Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.
- What are the ways to deploy an assembly? An MSI installer, a CAB archive, and XCOPY command.
- What’s a satellite assembly? When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.
- What namespaces are necessary to create a localized application? System.Globalization, System.Resources.
- What’s the difference between // comments, /* */ comments and /// comments? Single-line, multi-line and XML documentation comments.
- How do you generate documentation from the C# file commented properly with a command-line compiler? Compile it with a /doc switch.
- What’s the difference between <c> and <code> XML documentation tag? Single line code example and multiple-line code example.
- Is XML case-sensitive? Yes, so <Student> and <student> are different elements.
- What debugging tools come with the .NET SDK? CorDBG – command-line debugger, and DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch.
- What does the This window show in the debugger? It points to the object that’s pointed to by this reference. Object’s instance data is shown.
- What does assert() do? In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.
- What’s the difference between the Debug class and Trace class? Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.
- Why are there five tracing levels in System.Diagnostics.TraceSwitcher? The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities.
- Where is the output of TextWriterTraceListener redirected? To the Console or a text file depending on the parameter passed to the constructor.
- How do you debug an ASP.NET Web application? Attach the aspnet_wp.exe process to the DbgClr debugger.
- What are three test cases you should go through in unit testing? Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly).
- Can you change the value of a variable while debugging a C# application? Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.
- Explain the three services model (three-tier application). Presentation (UI), business (logic and underlying code) and data (from storage or other sources).
- What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET? SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix, but it’s a .NET layer on top of OLE layer, so not the fastest thing in the world. ODBC.NET is a deprecated layer provided for backward compatibility to ODBC engines.
- What’s the role of the DataReader class in ADO.NET connections? It returns a read-only dataset from the data source when the command is executed.
- What is the wildcard character in SQL? Let’s say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve ‘La%’.
- Explain ACID rule of thumb for transactions. Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions), Consistent (data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t), Isolated (no transaction sees the intermediate results of the current transaction), Durable (the values persist if the data had been committed even if the system crashes right after).
- What connections does Microsoft SQL Server support? Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords).
- Which one is trusted and which one is untrusted? Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.
- Why would you use untrusted verificaion? Web Services might use it, as well as non-Windows applications.
- What does the parameter Initial Catalog define inside Connection String? The database name to connect to.
- What’s the data provider name to connect to Access database? Microsoft.Access.
- What does Dispose method do with the connection object? Deletes it from the memory.
- What is a pre-requisite for connection pooling? Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings.
General Questions
http://blogs.crsw.com/mark/articles/252.aspx
- Does C# support multiple-inheritance?
- No.
- Who is a protected class-level variable available to?
- It is available to any sub-class (a class inheriting this class).
- Are private class-level variables inherited?
- Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.
- Describe the accessibility modifier “protected internal”.
- It is available to classes that are within the same assembly and derived from the specified base class.
- What’s the top .NET class that everything is derived from?
- System.Object.
- What does the term immutable mean?
- The data value may not be changed. Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory.
- What’s the difference between System.String and System.Text.StringBuilder classes?
- System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.
- What’s the advantage of using System.Text.StringBuilder over System.String?
- StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable, so each time a string is changed, a new instance in memory is created.
- Can you store multiple data types in System.Array?
- No.
- What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
- The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element’s object, resulting in a different, yet identacle object.
- How can you sort the elements of the array in descending order?
- By calling Sort() and then Reverse() methods.
- What’s the .NET collection class that allows an element to be accessed using a unique key?
- HashTable.
- What class is underneath the SortedList class?
- A sorted HashTable.
- Will the finally block get executed if an exception has not occurred?
- Yes.
- What’s the C# syntax to catch any possible exception?
- A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.
- Can multiple catch blocks be executed for a single try statement?
- No. Once the proper catch block processed, control is transferred to the finally block (if there are any).
- Explain the three services model commonly know as a three-tier application.
- Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources).
Class Questions
- What is the syntax to inherit from a class in C#?
- Place a colon and then the name of the base class.
- Example: class MyNewClass : MyBaseClass
- Can you prevent your class from being inherited by another class?
- Yes. The keyword “sealed” will prevent the class from being inherited.
- Can you allow a class to be inherited, but prevent the method from being over-ridden?
- Yes. Just leave the class public and make the method sealed.
- What’s an abstract class?
- A class that cannot be instantiated. An abstract class is a class that must be inherited and have the methods overridden. An abstract class is essentially a blueprint for a class without any implementation.
- When do you absolutely have to declare a class as abstract?
- 1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.
- 2. When at least one of the methods in the class is abstract.
- What is an interface class?
- Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes.
- Why can’t you specify the accessibility modifier for methods inside the interface?
- They all must be public, and are therefore public by default.
- Can you inherit multiple interfaces?
- Yes. .NET does support multiple interfaces.
- What happens if you inherit multiple interfaces and they have conflicting method names?
- It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay.
- To Do: Investigate
- What’s the difference between an interface and abstract class?
- In an interface class, all methods are abstract – there is no implementation. In an abstract class some methods can be concrete. In an interface class, no accessibility modifiers are allowed. An abstract class may have accessibility modifiers.
- What is the difference between a Struct and a Class?
- Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval. Another difference is that structs cannot inherit.
Method and Property Questions
- What’s the implicit name of the parameter that gets passed into the set method/property of a class?
- Value. The data type of the value parameter is defined by whatever data type the property is declared as.
- What does the keyword “virtual” declare for a method or property?
- The method or property can be overridden.
- How is method overriding different from method overloading?
- When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same name within the class.
- Can you declare an override method to be static if the original method is not static?
- No. The signature of the virtual method must remain the same. (Note: Only the keyword virtual is changed to keyword override)
- What are the different ways a method can be overloaded?
- Different parameter data types, different number of parameters, different order of parameters.
- If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?
- Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.
Events and Delegates
- What’s a delegate?
- A delegate object encapsulates a reference to a method.
- What’s a multicast delegate?
- A delegate that has multiple handlers assigned to it. Each assigned handler (method) is called.
XML Documentation Questions
- Is XML case-sensitive?
- Yes.
- What’s the difference between // comments, /* */ comments and /// comments?
- Single-line comments, multi-line comments, and XML documentation comments.
- How do you generate documentation from the C# file commented properly with a command-line compiler?
- Compile it with the /doc switch.
Debugging and Testing Questions
- What debugging tools come with the .NET SDK?
- 1. CorDBG – command-line debugger. To use CorDbg, you must compile the original C# file using the /debug switch.
- 2. DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR.
- What does assert() method do?
- In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.
- What’s the difference between the Debug class and Trace class?
- Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.
- Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
- The tracing dumps can be quite verbose. For applications that are constantly running you run the risk of overloading the machine and the hard drive. Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.
- Where is the output of TextWriterTraceListener redirected?
- To the Console or a text file depending on the parameter passed to the constructor.
- How do you debug an ASP.NET Web application?
- Attach the aspnet_wp.exe process to the DbgClr debugger.
- What are three test cases you should go through in unit testing?
- 1. Positive test cases (correct data, correct output).
- 2. Negative test cases (broken or missing data, proper handling).
- 3. Exception test cases (exceptions are thrown and caught properly).
- Can you change the value of a variable while debugging a C# application?
- Yes. If you are debugging via Visual Studio.NET, just go to Immediate window.
ADO.NET and Database Questions
- What is the role of the DataReader class in ADO.NET connections?
- It returns a read-only, forward-only rowset from the data source. A DataReader provides fast access when a forward-only sequential read is needed.
- What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?
- SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix. OLE-DB.NET is a .NET layer on top of the OLE layer, so it’s not as fastest and efficient as SqlServer.NET.
- What is the wildcard character in SQL?
- Let’s say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve ‘La%’.
- Explain ACID rule of thumb for transactions.
- A transaction must be:
- 1. Atomic – it is one unit of work and does not dependent on previous and following transactions.
- 2. Consistent – data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t.
- 3. Isolated – no transaction sees the intermediate results of the current transaction).
- 4. Durable – the values persist if the data had been committed even if the system crashes right after.
- What connections does Microsoft SQL Server support?
- Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and password).
- Between Windows Authentication and SQL Server Authentication, which one is trusted and which one is untrusted?
- Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.
- What does the Initial Catalog parameter define in the connection string?
- The database name to connect to.
- What does the Dispose method do with the connection object?
- Deletes it from the memory.
- To Do: answer better. The current answer is not entirely correct.
- What is a pre-requisite for connection pooling?
- Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings. The connection string must be identical.
Assembly Questions
- How is the DLL Hell problem solved in .NET?
- Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.
- What are the ways to deploy an assembly?
- An MSI installer, a CAB archive, and XCOPY command.
- What is a satellite assembly?
- When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.
- What namespaces are necessary to create a localized application?
- System.Globalization and System.Resources.
- What is the smallest unit of execution in .NET?
- an Assembly.
- When should you call the garbage collector in .NET?
- As a good rule, you should not call the garbage collector. However, you could call the garbage collector when you are done using a large object (or set of objects) to force the garbage collector to dispose of those very large objects from memory. However, this is usually not a good practice.
- How do you convert a value-type to a reference-type?
- Use Boxing.
- What happens in memory when you Box and Unbox a value-type?
- Boxing converts a value-type to a reference-type, thus storing the object on the heap. Unboxing converts a reference-type to a value-type, thus storing the value on the stack.
作者:Alexliu(alex dotNet Learning)
出处:http://alexliu.cnblogs.com/
原文是这样的,看不懂?看不懂就对了,以下是我的翻译:
- 在System.String上使用System.Text.StringBuilder有什么好处?StringBuilder在对文本进行大量操作的情况下效率更高。字符串是不可变的,因此每次操作时都会创建一个新实例。
- 你可以在System.Array中存储多种数据类型吗?没有。
- System.Array.CopyTo()和System.Array.Clone()之间有什么区别?第一个执行数组的深层复制,第二个执行浅层复制。
- 如何按降序对数组元素进行排序?通过调用Sort()然后调用Reverse()方法。
- 什么是允许通过唯一键检索数据的.NET数据类型?哈希表。
- 下面是什么类SortedList?已排序的HashTable。
- 将最终未发生异常块得到执行?是。
- 什么是C#等价的C ++ catch(…),这是任何可能的异常的全能语句?捕获块,捕获System.Exception类型的异常。在这种情况下,您也可以省略参数数据类型,只需编写catch {}。
- 可以执行多个catch块吗?不,一旦正确的catch代码触发,控件将被转移到finally块(如果有的话),然后是finally块后面的任何内容。
- 为什么抛出自己的异常是个坏主意?好吧,如果那时你知道发生了错误,为什么不编写正确的代码来处理该错误而不是将新的Exception对象传递给catch块?抛出自己的异常表示项目中存在一些设计缺陷。
- 什么是代表?委托对象封装了对方法的引用。在C ++中,它们被称为函数指针。
- 什么是多播代表?这是一个指向并最终触发几种方法的代表。
- 如何在.NET中解决DLL Hell问题?程序集版本控制允许应用程序不仅指定它需要运行的库(在Win32下可用),还指定程序集的版本。
- 部署程序集的方法有哪些?MSI安装程序,CAB存档和XCOPY命令。
- 什么是卫星装配?当您在.NET中编写多语言或多文化应用程序,并希望将核心应用程序与本地化模块分开时,修改核心应用程序的本地化程序集称为附属程序集。
- 创建本地化应用程序需要哪些名称空间?System.Globalization,System.Resources。
- //评论,/ * * /评论和///评论之间有什么区别?单行,多行和XML文档注释。
- 如何从命令行编译器正确评论的C#文件中生成文档?用/ doc开关编译它。
- <c>和<code> XML文档标记之间有什么区别?单行代码示例和多行代码示例。
- XML区分大小写吗?是的,所以<Student>和<student>是不同的元素。
- .NET SDK附带了哪些调试工具?CorDBG – 命令行调试器和DbgCLR – 图形调试器。Visual Studio .NET使用DbgCLR。要使用CorDbg,必须使用/ debug开关编译原始C#文件。
- 此窗口在调试器中显示什么?它指向此引用所指向的对象。显示对象的实例数据。
- assert()做什么?在调试编译中,assert将布尔条件作为参数,如果条件为false,则显示错误对话框。如果条件为真,程序将继续进行而不会中断。
- Debug类和Trace类有什么区别?文档看起来一样。将Debug类用于调试版本,对调试和发布版本使用Trace类。
- 为什么System.Diagnostics.TraceSwitcher中有五个跟踪级别?跟踪转储可能非常冗长,对于一些经常运行的应用程序,您可能会面临机器和硬盘驱动器过载的风险。五个级别从None到Verbose,允许微调跟踪活动。
- TextWriterTraceListener的输出重定向在哪里?到控制台或文本文件,具体取决于传递给构造函数的参数。
- 如何调试ASP.NET Web应用程序?将aspnet_wp.exe进程附加到DbgClr调试器。
- 在单元测试中你应该经历三个测试用例?正面测试用例(正确数据,正确输出),负面测试用例(数据损坏或丢失,正确处理),异常测试用例(异常被抛出并正确捕获)。
- 您可以在调试C#应用程序时更改变量的值吗?是的,如果您通过Visual Studio.NET进行调试,只需转到立即窗口。
- 解释三种服务模型(三层应用程序)。演示文稿(UI),业务(逻辑和底层代码)和数据(来自存储或其他来源)。
- ADO.NET中Microsoft提供的数据提供程序类的优缺点是什么?SQLServer.NET数据提供程序是高速且健壮的,但需要从Microsoft购买的SQL Server许可证。OLE-DB.NET是通用的,用于访问其他来源,如Oracle,DB2,Microsoft Access和Informix,但它是一个位于OLE层之上的.NET层,因此不是世界上最快的东西。ODBC.NET是一个不推荐使用的层,用于向后兼容ODBC引擎。
- DataReader类在ADO.NET连接中的作用是什么?执行命令时,它会从数据源返回只读数据集。
- SQL中的通配符是什么?假设您希望使用LIKE为名称以La开头的所有员工查询数据库。通配符是%,LIKE的正确查询将涉及’La%’。
- 解释交易的ACID经验法则。事务必须是Atomic(它是一个工作单元并且不依赖于先前和后续事务),一致(数据被提交或回滚,没有“中间”情况,其中某些事情已被更新而某些事情没有) ,隔离(没有事务看到当前事务的中间结果),持久(即使系统在之后崩溃,如果数据已提交,则值仍然存在)。
- Microsoft SQL Server支持哪些连接?Windows身份验证(通过Active Directory)和SQL Server身份验证(通过Microsoft SQL Server用户名和密码)。
- 哪一个是可信的,哪一个是不可信的?Windows身份验证是受信任的,因为使用Active Directory检查用户名和密码,SQL Server身份验证是不受信任的,因为SQL Server是参与事务的唯一验证者。
- 你为什么要使用不受信任的验证?Web服务可能会使用它,也可能使用非Windows应用程序。
- 参数初始目录在连接字符串中定义了什么?要连接的数据库名称。
- 连接到Access数据库的数据提供程序名称是什么?Microsoft.Access。
- Dispose方法对连接对象有什么作用?从内存中删除它。
- 连接池的先决条件是什么?多个进程必须同意它们将共享相同的连接,其中每个参数都相同,包括安全设置。
一般的问题
http://blogs.crsw.com/mark/articles/252.aspx
- C#是否支持多重继承?
- 没有。
- 谁是受保护的类级变量?
- 它可用于任何子类(继承此类的类)。
- 私有类级变量是否继承?
- 是的,但它们无法访问。虽然它们不可见或可通过类接口访问,但它们是继承的。
- 描述可访问性修饰符“protected internal”。
- 它适用于同一程序集中并从指定基类派生的类。
- 什么是顶级的.NET类,一切都源于什么?
- System.Object的。
- “不可变”一词是什么意思?
- 数据值可能不会更改。注意:变量值可以被改变,但原始不变数据值被丢弃并且新的数据值是在存储器中创建。
- System.String和System.Text.StringBuilder类有什么区别?
- System.String是不可变的。System.StringBuilder的设计目的是拥有一个可变字符串,可以执行各种操作。
- 在System.String上使用System.Text.StringBuilder有什么好处?
- 在存在大量字符串操作的情况下,StringBuilder更有效。字符串是不可变的,因此每次更改字符串时,都会在内存中创建一个新实例。
- 你可以在System.Array中存储多种数据类型吗?
- 没有。
- System.Array.CopyTo()和System.Array.Clone()之间有什么区别?
- Clone()方法返回一个包含原始数组中所有元素的新数组(浅复制)对象。CopyTo()方法将元素复制到另一个现有数组中。两者都执行浅拷贝。浅拷贝意味着内容(每个数组元素)包含与原始数组中的元素相同的对象的引用。深层副本(这些方法都不会执行)会创建每个元素对象的新实例,从而产生一个不同但同一性的对象。
- 如何按降序对数组元素进行排序?
- 通过调用Sort()然后调用Reverse()方法。
- 什么是.NET集合类,允许使用唯一键访问元素?
- 哈希表。
- SortedList类下面有什么类?
- 已排序的HashTable。
- 如果没有发生异常,是否会执行finally块?
- 是。
- 什么是C#语法来捕获任何可能的异常?
- 捕获块,捕获System.Exception类型的异常。在这种情况下,您也可以省略参数数据类型,只需编写catch {}。
- 可以为单个try语句执行多个catch块吗?
- 没有。一旦处理了正确的捕获块,控制就转移到finally块(如果有的话)。
- 解释通常称为三层应用程序的三种服务模型。
- 演示文稿(UI),业务(逻辑和底层代码)和数据(来自存储或其他来源)。
课堂提问
- 从C#中的类继承的语法是什么?
- 放置冒号,然后放置基类的名称。
- 示例: class MyNewClass:MyBaseClass
- 你可以阻止你的班级被另一个班级继承吗?
- 是。关键字“sealed”将阻止继承该类。
- 你能否允许继承一个类,但是防止该方法被过度使用?
- 是。只需将该类公开,并使该方法密封。
- 什么是抽象类?
- 无法实例化的类。抽象类是必须继承并重写方法的类。抽象类本质上是没有任何实现的类的蓝图。
- 你什么时候必须将一个类声明为抽象?
- 1.当类本身继承自抽象类时,但并非所有基本抽象方法都被重写。
- 2. 当类中至少有一个方法是抽象的时。
- 什么是接口类?
- 接口与类一样,定义了一组属性,方法和事件。但与类不同,接口不提供实现。它们由类实现,并从类中定义为单独的实体。
- 为什么不能为界面内的方法指定辅助功能修饰符?
- 它们都必须是公开的,因此默认是公开的。
- 你能继承多个接口吗?
- 是。.NET确实支持多个接口。
- 如果继承多个接口并且它们具有冲突的方法名称会发生什么?
- 您可以在自己的类中实现该方法,因此实现完全取决于您。如果来自不同接口的类似命名方法期望不同的数据,这可能会导致更高级别的问题,但就编译器而言,您可以接受。
- 待办事项:调查
- 接口和抽象类有什么区别?
- 在接口类中,所有方法都是抽象的 – 没有实现。在抽象类中,一些方法可以是具体的。在接口类中,不允许使用辅助功能修饰符。抽象类可能具有辅助功能修饰符。
- 结构和类之间有什么区别?
- 结构是值类型变量,因此保存在堆栈中,额外的开销但更快的检索。另一个区别是结构 不能继承。
方法和性质问题
- 传递给类的set方法/属性的参数的隐式名称是什么?
- 值。value参数的数据类型由声明属性的任何数据类型定义。
- 关键字“virtual”为方法或属性声明什么?
- 方法或属性可以被覆盖。
- 方法覆盖与方法重载有何不同?
- 覆盖方法时,可以更改派生类的方法行为。重载方法只需要在类中使用另一个具有相同名称的方法。
- 如果原始方法不是静态的,是否可以将覆盖方法声明为静态?
- 不可以。虚方法的签名必须保持不变。(注意:只有关键字virtual更改为关键字覆盖)
- 方法可以重载的方式有哪些?
- 不同的参数数据类型,不同的参数个数,不同的参数顺序。
- 如果基类有许多重载的构造函数,并且继承类有许多重载的构造函数; 你可以强制从继承的构造函数调用到特定的基础构造函数?
- 是的,只需放置冒号,然后在继承类内的重载构造函数定义中放置关键字base(参数列表以调用相应的构造函数)。
活动和代表
- 什么是代表?
- 委托对象封装了对方法的引用。
- 什么是多播代表?
- 分配了多个处理程序的委托。调用每个分配的处理程序(方法)。
XML文档问题
- XML区分大小写吗?
- 是。
- //评论,/ * * /评论和///评论之间有什么区别?
- 单行注释,多行注释和XML文档注释。
- 如何从命令行编译器正确评论的C#文件中生成文档?
- 使用/ doc开关编译它。
调试和测试问题
- .NET SDK附带了哪些调试工具?
- 1. CorDBG – 命令行调试器。 要使用CorDbg,必须使用/ debug开关编译原始C#文件。
- 2. DbgCLR – 图形调试器。 Visual Studio .NET使用DbgCLR。
- assert()方法有什么作用?
- 在调试编译中,assert将布尔条件作为参数,如果条件为false,则显示错误对话框。 如果条件为真,程序将继续进行而不会中断。
- Debug类和Trace类有什么区别?
- 文档看起来一样。 将Debug类用于调试版本,对调试和发布版本使用Trace类。
- 为什么System.Diagnostics.TraceSwitcher中有五个跟踪级别?
- 跟踪转储可能非常冗长。 对于经常运行的应用程序,您可能会面临机器和硬盘驱动器过载的风险。 五个级别从None到Verbose,允许您微调跟踪活动。
- TextWriterTraceListener的输出重定向在哪里?
- 到控制台或文本文件,具体取决于传递给构造函数的参数。
- 如何调试ASP.NET Web应用程序?
- 将aspnet_wp.exe进程附加到DbgClr调试器。
- 在单元测试中你应该经历三个测试用例?
- 1. 正面测试用例(正确的数据,正确的输出)。
- 2. 负面测试用例(数据损坏或丢失,正确处理)。
- 3. 异常测试用例(异常被抛出并正确捕获)。
- 您可以在调试C#应用程序时更改变量的值吗?
- 是。 如果您通过Visual Studio.NET进行调试,只需转到立即窗口。
ADO.NET和数据库问题
- DataReader类在ADO.NET连接中的作用是什么?
- 它从数据源返回只读,仅向前行集。当需要仅向前顺序读取时,DataReader提供快速访问。
- ADO.NET中Microsoft提供的数据提供程序类的优缺点是什么?
- SQLServer.NET数据提供程序是高速且健壮的,但需要从Microsoft购买的SQL Server许可证。OLE-DB.NET是通用的,用于访问其他来源,如Oracle,DB2,Microsoft Access和Informix。 OLE-DB.NET是一个位于OLE层之上的.NET层,因此它不像SqlServer.NET那样快速有效。
- SQL中的通配符是什么?
- 假设您想要使用LIKE为名称以…开头的所有员工查询数据库拉。 通配符是%,使用LIKE的正确查询将涉及’La%’。
- 解释交易的ACID经验法则。
- 交易必须是:
- 1。 原子 – 它是一个工作单元,不依赖于之前和之后的交易。
- 2. 一致 – 数据被提交或回滚,没有“中间”的情况,其中某些东西已经更新,而某些东西没有。
- 3. 隔离 – 没有事务看到当前事务的中间结果)。
- 4. 持久 – 即使系统在之后崩溃,如果数据已提交,则值仍然存在。
- Microsoft SQL Server支持哪些连接?
- Windows身份验证(通过Active Directory)和SQL Server身份验证(通过Microsoft SQL Server用户名和密码)。
- 在Windows身份验证和SQL Server身份验证之间,哪一个是受信任的,哪一个是不受信任的?
- Windows身份验证是受信任的,因为使用Active Directory检查用户名和密码,SQL Server身份验证是不受信任的,因为SQL Server是参与事务的唯一验证者。
- 初始目录参数在连接字符串中定义了什么?
- 要连接的数据库名称。
- Dispose方法对连接对象有什么作用?
- 从内存中删除它。
- 待办: 回答更好。 目前的答案并不完全正确。
- 连接池的先决条件是什么?
- 多个进程必须同意它们将共享相同的连接,其中每个参数都相同,包括安全设置。连接字符串必须相同。
大会问题
- 如何在.NET中解决DLL Hell问题?
- 程序集版本控制允许应用程序不仅指定它需要运行的库(在Win32下可用),还指定程序集的版本。
- 部署程序集的方法有哪些?
- MSI安装程序,CAB存档和XCOPY命令。
- 什么是卫星装配?
- 当您在.NET中编写多语言或多文化应用程序,并希望将核心应用程序与本地化模块分开时,修改核心应用程序的本地化程序集称为附属程序集。
- 创建本地化应用程序需要哪些名称空间?
- System.Globalization和System.Resources。
- .NET中最小的执行单元是什么?
- 大会。
- 什么时候应该在.NET中调用垃圾收集器?
- 作为一个好规则,你不应该调用垃圾收集器。但是,当您使用大对象(或一组对象)强制垃圾收集器从内存中处理那些非常大的对象时,您可以调用垃圾收集器。但是,这通常不是一个好习惯。
- 如何将值类型转换为引用类型?
- 使用拳击。
- Box和Unbox的值类型在内存中会发生什么?
- Boxing将值类型转换为引用类型,从而将对象存储在堆上。拆箱将引用类型转换为值类型,从而将值存储在堆栈中。
看完本文有收获?请转发分享给更多人!!!欢迎大家点赞,留言讨论,喜欢这篇文章可以分享给更多人,关注我每天更新分享有关程序员、科技、编程之类的文章!!!爱你们,,么么哒,,让我们一起愉快的玩耍把!!!
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://itzsg.com/17463.html