您的位置:首页 > 职场人生

转载: .net程序员偏向组件开发的面试题

2010-01-02 05:50 225 查看
转载自:http://www.mwilliams.info/archive/2005/07/net-interview-questions-2-answers.php

C# Component Developers

Juxtapose the use of override with new. What is shadowing?
--- Override redefines an inherited method which was marked as virtual or abstract, and its access level must be the same as the method it overrides. New allows you to completely hide an inherited member and create a different implementation of it with whatever attributes you choose. Shadowing is another name for disabling an inherited method and redefining it.

Explain the use of virtual, sealed, override, and abstract.
--- Virtual marks a method as overridable. Sealed marks a class as uninheritable. Override redefines a method declared as virtual. Abstract defines a class which cannot be instantiated, or a method which must be overriden in any derived classes.

Explain the importance and use of each component of this string: Foo.Bar, Version=2.0.205.0, Culture=neutral, PublicKeyToken=593777ae2d274679d
--- Assembly name -- used for loading. Assembly version -- also used for loading. Culture -- defines culture settings used for string translation and other locale-specific settings. PublicKeyToken -- used to uniquely identify this assembly and prevent collisions.

Explain the differences between public, protected, private and internal.
--- Public: accessible from any class. Private: accessible only from within the same class. Protected: like private, but derived classes may also access. Internal: like public, but accessible only by code within the same assembly.

What benefit do you get from using a Primary Interop Assembly (PIA)?
--- A PIA is a strongly-named assembly which defines COM interfaces for a component. Because it is strongly-named, it can be loaded into the GAC and verified against the COM component's own signature to give the component collision-protection and authorship-verification benefits when interacing with .NET code.

By what mechanism does NUnit know what methods to test?
--- Reading attributes defined for classes and methods via reflection.

What is the difference between: catch(Exception e){throw e;} and catch(Exception e){throw;}
--- Both statements will catch and throw exception, but the latter will preserve the original exception stack.
---
What is the difference between typeof(foo) and myFoo.GetType()?
--- The first returns the object's type at compile time; the second returns it at runtime.
---
Explain what’s happening in the first constructor: public class c{ public c(string a) : this() {;}; public c() {;} } How is this construct useful?
--- The first constructor invokes the base constructor in addition to its own functionality; this would be useful if your base initialized basic field values or had other code that all other constructors would utilize.

What is this? Can this be used within a static method?
--- The "this" reference refers to the current object context. Static methods have no context, so it is not valid.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: