每个优秀的 .NET 开发人员都应该能够回答的问题?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/365489/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Questions every good .NET developer should be able to answer?
提问by splattne
My company is about to hire .NET developers. We work on a variety of .NET platforms: ASP.NET, Compact Framework, Windowsforms, Web Services. I'd like to compile a list/catalog of good questions, a kind of minimum standard to see if the applicants are experienced. So, my question is:
我的公司即将招聘.NET 开发人员。我们在各种 .NET 平台上工作:ASP.NET、Compact Framework、Windowsforms、Web 服务。我想编制一份好问题的清单/目录,这是一种查看申请人是否有经验的最低标准。所以,我的问题是:
What questionsdo you think should a good .NET programmer be able to respond?
您认为优秀的.NET 程序员应该能够回答哪些问题?
I'd also see it as a checklistfor myself, in order to see where my own deficits are (there are many...).
我也将其视为我自己的清单,以便了解我自己的不足之处(有很多......)。


*UPDATE: It want to make clear that we're not testing only for .NET knowledge, and that problem solving capabilities and general programming skills are even more important to us.
*更新:它想表明我们不仅仅测试 .NET 知识,解决问题的能力和通用编程技能对我们来说更为重要。
采纳答案by Juliet
Basic questions include:
基本问题包括:
- Whats the difference between an abstract class and interface? When would you want to use them?
- What's the difference between a left join and an inner join?
- What's the difference between viewstate and sessionstate?
- What's the difference between overriding and overloading a method? Explain how both are done.
- What's the difference between protected and internal? What about "protected internal"?
- How do short-circuited operators work?
- Explain what the StringBuilder class is and why you'd want to use it?
- What's the difference between a static method and a non-static method?
- What does the "volatile" keyword in C# mean?
- Explain what happens when you pass a "ref" or "out" parameter into a method. What's the difference between those two keywords?
- What's a weakreference? When would you want to use one?
- What's the difference between a DataTable and a DataReader?
- What's the difference between a value-type and a reference type?
- What does the "readonly" keyword in C# mean?
- 抽象类和接口有什么区别?您想什么时候使用它们?
- 左连接和内连接有什么区别?
- 视图状态和会话状态有什么区别?
- 覆盖和重载方法有什么区别?解释两者是如何完成的。
- 受保护的和内部的有什么区别?“内部保护”呢?
- 短路运算符如何工作?
- 解释 StringBuilder 类是什么以及为什么要使用它?
- 静态方法和非静态方法有什么区别?
- C# 中的“volatile”关键字是什么意思?
- 解释将“ref”或“out”参数传递给方法时会发生什么。这两个关键字有什么区别?
- 什么是弱引用?你什么时候想用一个?
- DataTable 和 DataReader 之间有什么区别?
- 值类型和引用类型有什么区别?
- C# 中的“只读”关键字是什么意思?
I think it usually helps to ask your applicants to complete a simple coding exercise such as:
我认为要求申请人完成一个简单的编码练习通常会有所帮助,例如:
- Write your own linked list class without using the built-in classes.
- Write your own hashtable class without using the built-in classes.
- Write a class that represents a binary tree. Write a method that traverses all nodes of the tree.
- Write a method to perform a binary search on an array without using built-in methods.
- Draw a database schema for a blog. Each user only has one blog, each blog has many categories, each category has many posts, and each post can belong to more than one category. Ask your applicant to write queries to pull specific information out.
- 不使用内置类编写自己的链表类。
- 在不使用内置类的情况下编写您自己的哈希表类。
- 编写一个表示二叉树的类。编写一个遍历树的所有节点的方法。
- 编写一个不使用内置方法对数组进行二分查找的方法。
- 为博客绘制数据库模式。每个用户只有一个博客,每个博客有很多分类,每个分类有很多帖子,每个帖子可以属于多个分类。请您的申请人撰写查询以提取特定信息。
Next, look for specific technical know-how:
接下来,寻找具体的技术诀窍:
- (Event handlers) Create a class with a custom event handler, create another class which hooks onto the custom event handler.
- (XML) Load an XML document and select all of the nodes with properties x, y, and z.
- (Functional programming) Create a function that accepts another function as a parameter. A Map or Fold function works really good for this.
- (Reflection) Write a function which determines if a class has a particular attribute.
- (Regex) Write a regular expression which removes all tags from a block of HTML.
- (事件处理程序)创建一个带有自定义事件处理程序的类,创建另一个挂接到自定义事件处理程序的类。
- (XML) 加载一个 XML 文档并选择所有具有 x、y 和 z 属性的节点。
- (函数式编程)创建一个接受另一个函数作为参数的函数。Map 或 Fold 函数对此非常有用。
- (反射)编写一个函数来确定一个类是否具有特定属性。
- (Regex) 编写一个正则表达式,从 HTML 块中删除所有标签。
None of these are particularly difficult questions for a proficient C# programmer to answer, and they should give you a good idea of your applicants particular strengths. You may also want to work in a few questions/code sample that make use of specific design patterns.
对于精通 C# 的程序员来说,这些问题都不是特别难回答的问题,它们应该能让您对申请者的特殊优势有一个很好的了解。您可能还想解决一些使用特定设计模式的问题/代码示例。
[Edit for clarification]:
[编辑以澄清]:
Seems that a lot of people don't understand why I'd ask these types of questions. Let me touch on a few peoples comments (I'm not quoting directly, but paraphrasing instead):
似乎很多人不明白为什么我会问这些类型的问题。让我谈谈一些人的评论(我不是直接引用,而是转述):
Q:When was the last time anyone used volatiles or weak references?
问:最后一次有人使用 volatile 或弱引用是什么时候?
A:When I give technical interviews, I look to see whether a person understands the high-level andlow-level features of .NET. Volatiles and weak references are two low-level features provided by .NET -- even if these features aren't used often in practice, answers to these questions are extremely revealing:
A:我在做技术面试的时候,会看一个人是否了解.NET的高层和底层的特性。易失性和弱引用是 .NET 提供的两个低级特性——即使这些特性在实践中不经常使用,这些问题的答案也非常具有启发性:
A good understanding of volatiles demonstrates that a person understands how compiler optimizations change the correctness of code, how threads keep local copies of shared state which may be out of sync at any given time, and is minimally aware of some of the complexities of multithreaded code.
A good understanding of weak references demonstrates that a person knows about the intimate details of the garbage collector and how it decides when to free memory. Sure, you could ask candidates "how does a garbage collector work", but asking about weak references gets a much better, more thoughtful reply.
对 volatile 的良好理解表明,一个人了解编译器优化如何改变代码的正确性,线程如何保持在任何给定时间可能不同步的共享状态的本地副本,并且对多线程代码的某些复杂性知之甚少.
对弱引用的良好理解表明,一个人知道垃圾收集器的私密细节以及它如何决定何时释放内存。当然,你可以问候选人“垃圾收集器是如何工作的”,但询问弱引用会得到更好、更周到的答复。
.NET is a fairly abstract language, but star developers almost always have a deep understanding of the CLR and the low-level details of .NET's runtime.
.NET 是一种相当抽象的语言,但明星开发人员几乎总是对 CLR 和 .NET 运行时的低级细节有深入的了解。
Q:Why would anyone need to implement their own hashtable or linked list?
问:为什么有人需要实现自己的哈希表或链表?
A:I'm not implying that the Dictionary class is inferior or that people should roll their own hashtable. This is a basic question which tests whether a person has a minimalunderstanding of datastructures. Thats what these questions test for: bare minimum understanding.
A:我并不是在暗示 Dictionary 类低劣或人们应该推出自己的哈希表。这是一个基本问题,用于测试一个人是否对数据结构的了解最少。这就是这些问题所测试的:最低限度的理解。
You learn about these hashtables and linked lists on the first day of Data Structures 101. If someone can't write a hashtable or a linked list from scratch, then they have a hugegap in their technical knowledge.
你在数据结构 101 的第一天学习了这些哈希表和链表。如果有人不能从头开始编写哈希表或链表,那么他们的技术知识就有了巨大的差距。
Q:Why are these questions so crud-oriented?
问:为什么这些问题如此粗暴?
A:Because the title of this thread is "questions every good .NET developer should know". Every .NET developer begins their career writing crud apps, and 90% of all application development people do for a living is concerned with line-of-business applications.
答:因为这个帖子的标题是“每个优秀的 .NET 开发人员都应该知道的问题”。每个 .NET 开发人员的职业生涯都是从编写 crud 应用程序开始的,90% 的所有应用程序开发人员都与业务线应用程序有关。
I think questions testing a persons knowledge of line-of-business apps are appropriate in most cases, unless you're looking for developers in very specific niches, such as compiler development, game-engine development, theorem-proving, image processing, etc.
我认为在大多数情况下测试一个人的业务线应用程序知识的问题是合适的,除非您正在寻找非常特定领域的开发人员,例如编译器开发、游戏引擎开发、定理证明、图像处理等.
回答by splattne
I found these lists on Scott Hanselman's blog:
我在Scott Hanselman的博客上找到了这些列表:
Here are what I think are the most important questions from these posts divided into categories. I edited and re-arranged them. Fortunately for most of these questions there is already a good answer on Stack Overflow. Just follow the links (I will update them all ASAP).
以下是我认为这些帖子中最重要的问题,分为几类。我编辑并重新安排了它们。幸运的是,对于大多数这些问题,Stack Overflow 上已经有一个很好的答案。只需按照链接(我会尽快更新它们)。
Platform independent .NET questions
平台无关的 .NET 问题
- What is the difference between a threadand a process?
- What is the difference between an EXEand a DLL?
- What is strong-typingversus weak-typing?
- What is the difference between
a.Equals(b)anda == b? - What is boxing?
- Is string a value typeor a reference type?
- What is the Global Assembly Cache(GAC)? What problem does it solve?
- What is an Interfaceand how is it different from a Class?
- What is Reflection?
- Conceptually, what is the difference between early-bindingand late-binding?
- When would using
Assembly.LoadFromorAssembly.LoadFilebe appropriate? - What is an Asssembly Qualified Name? Is it a filename? How is it different?
- How is a strongly-named assemblydifferent from one that isn't strongly-named?
- What does this do? sn -t foo.dll
- How does the generational garbage collectorin the .NET CLR manage object lifetime? What is non-deterministic finalization?
- What is the difference between
Finalize()andDispose()?(external article) - What is the difference between in-procand out-of-proc? What technology enables out-of-proc communicationin .NET?
- What is FullTrust? Do GAC'ed assemblies have FullTrust?
- What is the difference between
Debug.WriteandTrace.Write? When should each be used? - What is the difference between a Debug and Release build?Is there a significant speed difference? Why or why not?
- What is the difference between:
catch (Exception e) {throw e;}and catch(Exception e) {throw;}? - What is the difference between
typeof(foo)andmyFoo.GetType()? - What is the purpose of XML Namespaces?
- What is the difference between an XML "Fragment" and an XML "Document"? (XML Basics)
- How would you validate XMLusing .NET?
- 线程和进程有什么区别?
- EXE和DLL 有什么区别?
- 什么是强类型与弱类型?
a.Equals(b)和 和有a == b什么区别?- 什么是拳击?
- 字符串是值类型还是引用类型?
- 什么是全局程序集缓存(GAC)?它解决什么问题?
- 什么是接口,它与类有什么不同?
- 什么是反射?
- 从概念上讲,早绑定和晚绑定有什么区别?
- 什么时候使用
Assembly.LoadFrom或Assembly.LoadFile合适? - 什么是程序集限定名称?是文件名吗?它有什么不同?
- 如何是一个强命名程序集不同于一个不强命名的?
- 这有什么作用?sn -t foo.dll
- 如何世代垃圾收集在.NET CLR管理对象的生命周期?什么是非确定性终结?
Finalize()和 和有Dispose()什么区别?(外文)- 进程内和进程外有什么区别?什么技术支持.NET中的进程外通信?
- 什么是FullTrust?GAC 的程序集是否具有 FullTrust?
Debug.Write和 和有Trace.Write什么区别?每个应该什么时候使用?- 调试版本和发布版本有什么区别?有明显的速度差异吗?为什么或者为什么不?
catch (Exception e) {throw e;}和 catch 有(Exception e) {throw;}什么区别?typeof(foo)和 和有myFoo.GetType()什么区别?- XML 命名空间的目的是什么?
- XML“片段”和XML“文档”有什么区别?(XML 基础)
- 您将如何使用 .NET验证 XML?
ASP.NET
ASP.NET
- What is a PostBack?
- What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState? Why is it either useful or evil?
- What Session State providersare available in ASP.NET? What are the pros and cons of each?
- What is the OO relationship between an ASPX page and its CS/VB code behindfile?
- How would one implement ASP.NET HTML output caching, caching outgoing versions of pages generated via all values of
q=except whereq=5(as inhttp://localhost/page.aspx?q=5)? - What are HttpHandlers?
- What are HttpModules?
- What is needed to configure a new extensionfor use in ASP.NET? For example, what if I wanted my system to serve ASPX files with a *.jsp extension?
- How do cookieswork?What is an example of Cookie abuse?
- What kind of data is passed via HTTP Headers?
- How does IIS communicate at runtimewith ASP.NET? Where is ASP.NET at runtime in the different versions of IIS (5 to 7)?
- 什么是回发?
- 什么是视图状态?它是如何编码的?是加密的吗?谁使用 ViewState?为什么它是有用的还是邪恶的?
- ASP.NET 中有哪些会话状态提供程序可用?各自的优缺点是什么?
- ASPX 页面与其 CS/ VB 代码隐藏文件之间的OO 关系是什么?
- 如何实现ASP.NET HTML输出缓存,缓存通过
q=除 whereq=5(如http://localhost/page.aspx?q=5)的所有值生成的页面的传出版本? - 什么是HttpHandler?
- 什么是HttpModules?
- 在 ASP.NET 中配置新扩展需要什么?例如,如果我希望我的系统为带有 *.jsp 扩展名的 ASPX 文件提供服务怎么办?
- 饼干是如何工作的?什么是 Cookie 滥用的示例?
- 通过HTTP Headers传递什么样的数据?
- IIS如何在运行时与 ASP.NET通信?在不同版本的 IIS(5 到 7)中,运行时 ASP.NET 在哪里?
回答by Brian MacKay
This might not be what you want to hear, but I would recommend not focusing on narrow technologies, but on general programming and problem solving skills. Solid developers can learn whatever you want them to do quickly.
这可能不是你想听到的,但我建议不要关注狭隘的技术,而是关注一般的编程和解决问题的技能。可靠的开发人员可以快速学习您希望他们做的任何事情。
I, for instance, am not a Compact Framework guy, so I might fail your interview if you went that direction. But if I needed to use it I could do some research and jump right in.
例如,我不是一个紧凑框架的人,所以如果你朝那个方向走,我可能会失败你的面试。但如果我需要使用它,我可以做一些研究并立即投入使用。
Joel's book, Smart and Gets Things Done, has great advice for hiring devs and there are large juicy sections about the kinds of questions to ask. I highly recommend it.
Joel 的书Smart and Gets Things Done为招聘开发人员提供了很好的建议,并且有大量关于要问的问题类型的有趣部分。我强烈推荐它。
回答by Jon Skeet
I think if I were interviewing someone who had LINQ experience, I'd possibly justask them to explain LINQ. If they can explain deferred execution, streaming, the IEnumerable/IEnumerator interfaces, foreach, iterator blocks, expression trees (for bonus points, anyway) then they can probably cope with the rest. (Admittedly they could be "ok" developers and not "get" LINQ yet - I'm really thinking of the case where they've claimed to know enough LINQ to make it a fair question.)
我想如果我在采访有 LINQ 经验的人,我可能只会让他们解释 LINQ。如果他们可以解释延迟执行、流、IEnumerable/IEnumerator 接口、foreach、迭代器块、表达式树(无论如何都是为了加分),那么他们可能可以应付其余的。(诚然,他们可能是“还不错”的开发人员,但还没有“获得”LINQ——我真的在考虑他们声称了解足够多的 LINQ 以使其成为一个公平的问题的情况。)
In the past I've asked several of the questions already listed, and a few others:
过去,我问了几个已经列出的问题,还有一些其他问题:
- Difference between reference and value types
- Pass by reference vs pass by value
- IDisposable and finalizers
- Strings, immutability, character encodings
- Floating point
- Delegates
- Generics
- Nullable types
- 引用类型和值类型之间的区别
- 按引用传递与按值传递
- IDisposable 和终结器
- 字符串、不变性、字符编码
- 浮点
- 代表
- 泛型
- 可空类型
回答by ChrisA
I'm with the guys that are looking for problem-solving abilities rather than the sort of thing you can look up and memorise from '101 top .NET interview Qs and As".
我和那些正在寻找解决问题能力的人在一起,而不是那种你可以从 '101 顶级 .NET 面试 Qs 和 As”中查找和记忆的东西。
Just to cite myself as an example, I tend to 'know' the things I need to use from day to day. I tend to forget (and later have to re-look up) things that I use rarely.
以我自己为例,我倾向于“知道”我每天需要使用的东西。我倾向于忘记(后来不得不重新查找)我很少使用的东西。
If you wanted to trip me up in an interview, it would be very easy.
如果你想在面试中绊倒我,那会很容易。
Nevertheless, I have architected and coded much of the infrastructure for a system that uses identical Business Objects and Data layers for its WinForms and ASP.NET incarnations, and our codebase is robust and reusable enough for us to be able to support and develop 20+ differently configured versions of the web site, as well as an increasing number (currently 5) of the WinForms application...
尽管如此,我已经为一个使用相同业务对象和数据层的系统设计和编码了它的 WinForms 和 ASP.NET 化身,我们的代码库足够健壮和可重用,足以支持和开发 20 多个网站的不同配置版本,以及越来越多的 WinForms 应用程序(目前为 5 个)...
... with a development team of two.
... 由两人组成的开发团队。
I used to work on a team as a tech lead, and my job involved quite a lot of recruiting and interviewing. My most spectacular mistake was hiring a guy that knew more about the technology we were using than all the rest of us put together, including me, and I counted myself as an expert. He knew everything...
我曾经在一个团队中担任技术主管,我的工作涉及很多招聘和面试。我最严重的错误是雇佣了一个比我们其他人加起来更了解我们正在使用的技术的人,包括我,我认为自己是专家。他什么都知道……
... except how to write code that either met the requirements, or could be understood by anyone except himself. When I eventually persuaded the PM not to renew his contract, every single thing he wrote had to be rewritten.
...除了如何编写满足要求或除了他自己以外的任何人都可以理解的代码。当我最终说服总理不要续约时,他写的每一件事都必须重写。
Structure your interviews wisely...
明智地安排你的面试……
回答by Steven A. Lowe
Who is Jon Skeet?
乔恩·斯基特是谁?
回答by qui
Good questions I have been asked are
我被问到的好问题是
- What do you think is goodabout .NET?
- What do you think is badabout .NET?
- 你认为.NET 有什么好处?
- 您认为.NET 的哪些方面不好?
It would be interesting to see what a candidate would come up with and you'll certainly learn quite a bit about how he/she uses the framework.
看看候选人会想出什么会很有趣,你肯定会学到很多关于他/她如何使用框架的知识。
回答by Jennifer
I would always look for the soft skills myself - no pun intended. So good OO design, test driven development, a good multi (programming) lingual background and all round general smartness (and getting-things done-ness I guess!).
我总是自己寻找软技能 - 没有双关语。如此优秀的面向对象设计、测试驱动的开发、良好的多(编程)语言背景和全面的智慧(我猜是把事情做好!)。
An intelligent developer should not have any trouble learning the individual technologies that you need them to know even if they have never looked at them before - so I wouldn't worry too much about specific questions around WCF/compact framework and the like.
一个聪明的开发人员在学习你需要他们了解的个别技术时应该不会有任何困难,即使他们以前从未看过它们 - 所以我不会太担心围绕 WCF/compact 框架等的具体问题。
I would have them write some code - best way to find out what they know and how they work. Anyone can memorise the answer to 'What's the difference between a reference type and a value type?'
我会让他们写一些代码 - 找出他们知道什么以及他们如何工作的最佳方式。任何人都可以记住“引用类型和值类型之间有什么区别?”的答案。
回答by Erik Funkenbusch
Honestly?
诚实地?
"What is .NET?"
“什么是.NET?”
If they can give you a clear answer as to what .NET is and what it isn't, how it's used, what elements it's composed of, etc... If they can convince you they know what it is, then chances are they know it pretty well.
如果他们可以就 .NET 是什么、不是什么、它是如何使用的、它由哪些元素组成等等给你一个明确的答案......如果他们能说服你他们知道它是什么,那么他们很有可能非常了解它。
The fact of the matter is, many people don't really know what .NET is. Even those who write programs for it.
事实是,很多人并不真正了解.NET 是什么。即使是那些为它编写程序的人。
回答by Gene Roberts
None, really. There are probably very simple questions that the smartest people in the world do not know the answers to. Not because they are hard, but simply because they just haven't come across it. You should be looking at the whole package and the skill of the developer, not whether they can answer an arbitrary question.
没有,真的。世界上最聪明的人可能不知道一些非常简单的问题。不是因为他们很难,而是因为他们只是没有遇到过。您应该查看整个程序包和开发人员的技能,而不是他们是否可以回答任意问题。
If the question is easy enough to be answered in a short sentence or two, it's easy enough to just tell someone who doesn't know. You should be looking for their understanding of concepts and reasoning capability, not their ability to answer questions "every .NET developer should be able to answer."
如果问题很简单,可以用一两句话来回答,那么告诉不知道的人就很容易了。您应该寻找他们对概念和推理能力的理解,而不是他们回答“每个 .NET 开发人员都应该能够回答的问题”的能力。

