C# 面经

本文详细解析了C#开发中的关键知识点,包括Page页面生命周期的各个阶段,Session与Cookie的关系及在禁用Cookie情况下的处理,以及装箱和坼箱操作对系统性能的影响。此外,还介绍了XML中XmlDocument与XmlReader的区别,接口与抽象类的异同,以及WCF(Windows Communication Foundation)的基本概念、主要特点与与Web服务的区别。面试中这些知识点都是C#开发者必备的。
摘要由CSDN通过智能技术生成

1.叙述Page页面的生命周期。(即写出Page几个主要的事件运行顺序)   
  对象初始化   OnInit   
  加载视图状态数据   LoadViewState   
  处理回传数据   LoadPostData   
  对象加载   Load   ->   OnLoad   
  激发RaisePostDataChanged   事件   
  处理客户端回传事件   RaisePostBackEvent   
  对象预呈现   OnPreRender   
  保存视图状态   SaveViewState   
  呈现HTML   Render   
  释放   Dispose  

 

2.Session跟Cookie有什么关系?   假如IE禁止使用cookie,那Session还有用吗?   
  当用户浏览站点时,服务器为该用户建立唯一的Session,Session的生命周期一直到用户访问结束。ASP.NET   会为每个Session维护会话状态信息,应用程序可在会话状态信息中存储用户特定信息。   
  ASP.NET   必须跟踪每个用户的Session   ID,以便可以将用户映射到服务器上的会话状态信息。默认情况下,ASP.NET   使用非永久性   Cookie   来存储会话状态。   
  如果用户已在IE上禁用   Cookie,会话状态信息便无法存储在   Cookie   中。   
  ASP.NET   提供了无   Cookie   会话作为替代。可以将应用程序配置为不将会话   ID   存储在   Cookie   中,而存储在站点中页面的   URL   中。

 

3. 如何理解装箱、坼箱操作?   运用此操作时对系统性能有什么影响?   
  装箱   ->   从值类型转换为引用类型   坼箱反之   
  创建引用类型会比创建值类型的系统开销要大得多,因为它在   
  堆上创建了对象,消耗了内存。而值类型却只把值保存在了线程堆栈上。   
  所以运用此操作时对系统性能有什么影响就不用说了吧?

 

4. XML中的XmlDocument跟   XmlReader有什么区别?   
  XmlDocument用于读取、操作和修改   XML   文档。XmlReader   类也读取   XML,但它提供非缓存的只进、只读访问。这意味着使用   XmlReader   无法编辑属性值或元素内容,或无法插入和移除节点

 

5. 接口跟抽象有什么异同?   你在平时项目设计过程中何时使用接口?   何时使用抽象类?   
  接口只能包含方法   属性   索引器   事件四种成员   
  抽象类的主要目的是用于继承,表达一种   is-a   什么是什么的关系   
  而接口传达的是has-abilities   具有某种能力   的概念   
  除非是非常强烈的is-a关系,才用抽象类.其它的情况都优先考虑使用接口.

 

What is WCF?
Windows Communication Foundation (WCF) is an SDK for developing and deploying services on Windows. WCF provides a runtime environment for services, enabling you to expose CLR types as services, and to consume other services as CLR types. WCF is part of .NET 3 and requires .NET 2, so it can only run on systems that support it.


What is three major points in WCF?
We should remember "ABC". Address specifies the location of the service. Binding specifies how the two parties will communicate in terms of transport, encoding and protocols. Contract specifies the interface between client and the server. It's a simple interface with some attribute.


What is "Endpoint" in WCF?
Every service must have an Address that defines where the service resides, a Contract that defines what the service does, and a Binding that defines how to communicate with the service. In WCF the relationship between Address, Contract and Binding is called Endpoint. The Endpoint is the combination of Address, Contract and Binding.


What is Proxy and how to generate proxy for WCF Services?
The proxy is a CLR class that exposes a single CLR interface representing the service contract. The proxy provides the same operations as service's contract, but also has additional methods for managing the proxy life cycle and the connection to the service. The proxy completely encapsulates every aspect of the service: its location, its implementation technology and runtime platform, and the communication transport.

A proxy can be generated using Visual Studio by right clicking Reference and clicking on Add Service Reference, where you need to supply the base address of the service and the namespace to contain the proxy. Proxy can also be generated by using SvcUtil.exe command-line utility.


Difference between WCF and Web Services?
Web Services can be accessed only over HTTP. It works in stateless environment. WCF is flexible because its services can be hosted in different types of applications: IIS, WAS (Windows Activation Service), Self-hosting and Managed Windows Service. By Self-hosting, we mean a service will be hosted in its own application domain. The service comes in to existence when you create the object of ServiceHost class, and closes when you call the Close of the ServiceHost class.

 

 

=================================

 

1) 描述线程与进程的区别?

线 程(Thread)与进程(Process)二者都定义了某种边界,不同的是进程定义的是应用程序与应用程序之间的边界,不同的进程之间不能共享代码和数 据空间&

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值