An Examine Paper for .Net Programmer
Part I C# Programming Basis1. int a=10, int b=15. Please write a piece of code to swap a and b without using a third variable. (10)2. There is an array int[] max={6,5,2,9,7,4,0}. Please implement a Quick Sort method to sort this array order by descendent, and return the sorted array. (15)3. There are 2 sentences. Please implement a function to find out the words in one sentence that does not appear in the another one. (15)4. Write Unit Test Cases for the C# function you have written for Question
Convert Array of Objects to Data Table
Normally in a web application, the Presentation Layer retrieves an Array/Collection of business objects as the data source to bind to GridView control. However sometimes we do need a DataTable to return. In such cases we need convert an Array/Collection of object to a DataTable.Now let's look into te code.[C#]public DataTable ConvertArrayToTable(Array myList){DataTable dt = new DataTable();if (myList.Length > 0){PropertyInfo[] propInfos = myList.GetValue(0).GetType().GetProperties();foreach (
Managing Namespaces in VB.Net
A namespace is a way to disambiguate one public interface from another. You can happily go through life not worrying about explicitly declaring namespaces in your VB.Net code because of VB.Net's automatic namespace creation. So you can create a project, give it a name, and start writing code. Beautiful and blissful.Then one day, you wake up and the solution your team works on won't compile.This will happen to you as a result of not managing your projects' namespaces properly. Eventually, you wil
.net 2.0 Nullable泛型结构的应用
.Net framework 2.0 新增了Nullable泛型结构。它表示基础类型为值类型的对象,值类型与引用类型一样也可以分配空(null)引用。示例代码:public class Employee {private int _id;private string _name;private string? _gender;private Datetime? _birthday;public string? Gender {get {return _gender;}set {_gender = value;}}public Datetime? Birthday {get {return _birthday;}set {_birthday = value;}}}public EmployeeClient {Employee emp = new Employee();emp.Name = "james";emp.Gender = null;emp.Birthday=nul
自定义TextBox控件的实现
需求:在实际应用开发中,经常需要查找某些数据实体,返回其Name和ID,然后执行相关的业务操作。通常,通过一个“查找”按钮,弹出一个模态窗体,执行查找,然后返回数据给父窗体。为了重用的需要,特开发一个TextBox控件,实现上述需求。Code:using System;using System.ComponentModel;using System.Text;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.ComponentModel.Design;namespace Beyondsoft.GDMP.AspNetControls{/// <summary>/// 用户选择控件/// </summary>
自定义DropDownList控件的实现
需求:要求DropDownList控件支持文本输入方式快速定位选择项。输入文本后按Tab键或Enter键触发SelectedIndexChanged事件。Code:using System;using System.Web.UI;using System.Web.UI.WebControls;using System.ComponentModel;using System.ComponentModel.Design;using System.Configuration;namespace Com.Elong.Commission.WebControl{/// <summary>/// DropDownListExtend 的摘要说明。/// </summary>[DefaultProperty("Text"), ToolboxData("<{0}:DropDownListExtend runat=server></{0}:Dro