云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > Net软件工程师面试题

Net软件工程师面试题

  • 62 次阅读
  • 3 次下载
  • 2025/5/23 16:14:32

} }

输出结果为: 2 5 1 6

(一个函数的执行必须在一个具体的对象中实现,如果函数明确告诉是哪个对象,则在改该对象下执行;如果没有,则在默认的对象下执行) 4. 在下面的例子里 using System; class A {

public A() {

PrintFields(); }

public virtual void PrintFields(){} }

class B:A {

int x=4; int y; public B() { y=-1; }

public override void PrintFields() {

x += 1;

Console.WriteLine(\ y += 1; }

当使用B b = new B()创建的实例时,产生什么输出?b. PrintFields();结果是什么?

X=5,y=0

b. PrintFields 结果是x=6;y=1

5. 下面的例子中

using System; class A {

public static int X; static A()

{

X=B.Y+1; }

} class B {

public static int Y=A.X+1; static B() { }

static void Main()

{

Console.WriteLine(\ } }

产生的输出结果是什么? X=2,Y=1

五.程序设计(每题7分,共28分) 1. 请编程实现一个冒泡排序算法?

//比较法 using System;

using System.Collections.Generic; using System.Text;

namespace test1 {

class Program

{

static void Main(string[] args) {

int[] Array ={ 6,18,12,23,19,28,30}; Console.WriteLine(\排序前的数组:\); foreach(int n in Array) {

Console.Write(n+\); }

Console.WriteLine();

for (int i = 1; i < Array.Length; i++) //控制趟数

{

for (int j = 0; j < Array.Length - i; j++)

{

if (Array[j] > Array[j + 1]) //交换

{

int temp = Array[j]; Array[j] = Array[j + 1]; Array[j + 1] = temp; } } } //排序后

Console.WriteLine(\排序后的数组:\); for (int n = 0; n < Array.Length; n++) {

Console.Write(Array[n] + \); }

Console.WriteLine(); } } }

2. 编程程序实现委托,事件。

using System;

using System.Collections.Generic; using System.Text;

namespace delegateDemo {

class Program {

static void Main(string[] args) {

Cat cat = new Cat(); Mouse mouse = new Mouse(); Master master = new Master(); cat.Calling += new EventHandler(mouse.Escape); cat.Calling += new EventHandler(master.Wakened); cat.Call(); } }

public sealed class Cat //猫类 {

public event EventHandler Calling; public void Call() {

Console.WriteLine(\猫开始叫了……\);

if(Calling!=null) //检查事件是否被注册

Calling(this,EventArgs.Empty);//调用事件注册的方法

} }

public sealed class Mouse //老鼠类 {

public void Escape(object sender, EventArgs e)

搜索更多关于: Net软件工程师面试题 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

} } 输出结果为: 2 5 1 6 (一个函数的执行必须在一个具体的对象中实现,如果函数明确告诉是哪个对象,则在改该对象下执行;如果没有,则在默认的对象下执行) 4. 在下面的例子里 using System; class A { public A() { PrintFields(); } public virtual void PrintFields(){} } class B:A { int x=4; int y; public B() { y=-1; } public overri

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com