1.列出所有可用于两个页面之间传递参数的方法。
2.打开一个HTML页面,要自动提交页面的一个form,如何实现?请简单写出相关的页面代码(包括form的主要代码)
3.C#的类中,函数Public,Private,Protect,internal限定符各有什么区别?
4.你对.net的GC的理解,不能超过300字。
5.请写一个查询语句:从user表中取出name列中的起始字符是“北京”的全部记录
6.请你简单的说明数据库建立索引的优缺点
7.如果禁用了cookie,是否会影响到session的使用?原因?
8.C#中Finalize,Dispose有什么不同?
9.最大公约数
既能被两个整数整除的最大整数,例如,24与15两个数的最大公约数为3.求最大公约数可以用求余法来实现。即用两个整数中最大的整数除以最小的数求余数,然后使用除数除以余数求余,直到余数为0时,之前的除数也就是两个数的最大公约数。
10.求素数的程序
A.The algorithm is quite simple.Given an array of integers starting at 2.Cross out all multiples of 2.Find the next uncrossed integer,and cross out all of its multiples.Repeat until you have passed the square root of the maximum value.
A.请翻译上述文字。
B.编程 要求输入一个正整数(可以写死在程序中),返回小于这个数的所有素数。
答案:
(1)
页面传值方式有7:
1 session
2 server.Tranfer
3.application
4 cookie
5 url
6 数据库
7隐藏域
querystring
(2)
<html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <script type="text/javascript"> window.onload=function() { window.form1.submit(); } </script></head><body><formid="form1" action="target.aspx" method="post"><inputid="txtName" name="txtName" type="text" value="hello" /><inputtype="submit" value="test"/></form></body></html>
C# code
protected void Page_Load( object sender, EventArgs e) { Response.Write(Request.Form.Get( " txtName " )); }
8 Finalize是对象不可访问后自动被调用 ,而Dispose则是使用者调用。
DisposE可以释放资源 ,而close不释放,仅仅是关闭而已
6. 索引可以避免全表扫描。
聚集索引可以避免数据插入操作集中于表的最后一个数据页
索引还可用于避免排序操作
索引需要占物理空间
7.客户端禁用Cookie,Session也会失效。参考
8.
都是进行垃圾回收的接口,作用都是回收外部资源(即非托管资源)。GC只能回收托管内存,非托管内存需要自己实现回收。
Finalize为protected方法,外部不可见。Dispose则用于被外部或用户调用,很多时候Dispose方法等同于该类的Close方法,即具备Dispose方法的类都有对应的Close方法
最大公约数
static int CommonDivisor(int x, int y)
{
if (x > y)
{
if (y == 0)
{
return x;
}
return CommonDivisor(y, x % y);
}
else if (x == y)
{
return x;
}
else
{
return CommonDivisor(x, y % x);
}
}
10.求素数
-
C# code
-
static void Main( string [] args) { int su = 36 ; GetSushu(su); Console.Read(); } public static void GetSushu( int su) { bool flag = false ; for ( int i = 2 ; i < su; i ++ ) { int j = 2 ; while ( ! flag && j < i) { if (i % j == 0 ) flag = true ; else j ++ ; } if ( ! flag) { Console.WriteLine(i); } flag = false ; } }
9.最大公约数:C# code
static void Main( string [] args) { int [] nums = new int [ 4 ] { 756 , 504 , 630 , 2226 }; Console.Write(GetGongYue(nums)); Console.Read(); } public static int GetGongYue( int [] nums) { int first = 0 ; int temp = nums[ 1 ]; for ( int i = 0 ; i < nums.Length; i ++ ) { first = nums[i]; while (first % temp != 0 ) { int temp2 = first; first = temp; temp = temp2 % temp; } } return temp; }