一级日韩免费大片,亚洲一区二区三区高清,性欧美乱妇高清come,久久婷婷国产麻豆91天堂,亚洲av无码a片在线观看

新蛋科技.net工程方面的筆試題

時(shí)間:2022-10-26 23:04:56 筆試題目 我要投稿
  • 相關(guān)推薦

新蛋科技.net工程方面的筆試題

  1、 DataSet和DataReader的區別和相同點(diǎn),分別適合用于什么樣的情況?

新蛋科技.net工程方面的筆試題

  答:

  2、 有基類(lèi)如下:

  public class parent

  {

  public parent()

  {

  Console.Write(“Parent”);

  }

  }

  請寫(xiě)出一個(gè)子類(lèi)Son,要求子類(lèi)的構造函數實(shí)現如下的功能:(1)輸出兒子的NAME、SEX、AGE、以及Parent,(2)要求在Son的構造函數里不能有任何的命令語(yǔ)句出現。

  public class parent

  {

  public parent()

  {

  Console.Write(“Parent”);

  }

  }

  public class Son:parent

  { static string name=null;

  static int sex=0;

  static int age=0;

  public parent(string name,int sex,int age):base()

  {

  name=name;

  sex=sex;

  age=age;

  display();

  }

  publci void display()

  {

  Console.WriteLine(“name=”+name);

  Console.WriteLine(“sex=”+sex);

  Console.WriteLine(“age=”+age);

  }

  }

  3、 請例舉出三種以上進(jìn)行頁(yè)面重定向的方式(包括服務(wù)端和客戶(hù)端)。

  答: 第一種: Response.Redirect,

  第二種: Server.Transfer

  第三種:

  function redirect(url) {

  document.theForm.action = url;

  document.theForm.submit();

  }

  第四種: StringBuilder sb=new StringBuilder();

  sb.Append(“ ”);

  Response.Write(sb.ToString());

  4、 寫(xiě)出禁用ViewState的語(yǔ)句。

  答: Control(具體的某個(gè)控件).EnableViewState=false;

  5、 請談一談.NET的code-behind模式和code_clude模式的區別,和各自的優(yōu)點(diǎn)及缺點(diǎn)。

  6、 寫(xiě)出下列七個(gè)程序段的輸出結果:

  (1)

  interface InFace

  {

  void fun();

  }

  class MyParent:InFace

  {

  public void fun()

  {

  Console.WriteLine(“Parent”);

  }

  }

  class MySon:MyParent

  {

  public void fun()

  {

  Console.WriteLine(“Son”);

  }

  }

  public class MyTest

  {

  public static void Main(string[] args)

  {

  InFace inf=new MySon();

  inf.fun();

  }

  }

  結果:Parent

  (2)

  interface InFace

  {

  void fun();

  }

  class MyParent:InFace

  {

  public new void fun()

  {

  Console.WriteLine(“Parent”);

  }

  }

  class MySon:MyParent

  {

  public void fun()

  {

  Console.WriteLine(“Son”);

  }

  }

  public class MyTest

  {

  public static void Main(string[] args)

  {

  InFace inf=new MySon();

  inf.fun();

  Console.Read();

  }

  }

  結果:Parent

  (3)

  interface InFace

  {

  void fun();

  }

  class MyParent:InFace

  {

  public new void fun()

  {

  Console.WriteLine(“Parent”);

  }

  }

  class MySon:MyParent

  {

  public new void fun()

  {

  Console.WriteLine(“Son”);

  }

  }

  public class MyTest

  {

  public static void Main(string[] args)

  {

  InFace inf=new MySon();

  inf.fun();

  Console.Read();

  }

  }

  結果:Parent

  (4)

  interface InFace

  {

  void fun();

  }

  class MyParent:InFace

  {

  public void fun()

  {

  Console.WriteLine(“Parent”);

  }

  }

  class MySon:MyParent

  {

  public override void fun()

  {

  Console.WriteLine(“Son”);

  }

  }

  public class MyTest

  {

  public static void Main(string[] args)

  {

  InFace inf=new MySon();

  inf.fun();

  Console.Read();

  }

  }

  結果:語(yǔ)法錯誤: 無(wú)法重寫(xiě)繼承成員“ConsoleApplication6.MyParent.fun()”,因為它未標記為 virtual、abstract 或 override

  (5)

  interface InFace

  {

  void fun();

  }

  abstract class MyParent:InFace

  {

  public virtual void fun()

  {

  Console.WriteLine(“Parent”);

  }

  }

  class MySon:MyParent

  {

  public override void fun()

  {

  Console.WriteLine(“Son”);

  }

  }

  public class MyTest

  {

  public static void Main(string[] args)

  {

  InFace inf=new MySon();

  inf.fun();

  Console.Read();

  }

  }

  結果:Son

  (6)

  interface InFace

  {

  void fun();

  }

  class MyParent:InFace

  {

  public virtual void fun()

  {

  Console.WriteLine(“Parent”);

  }

  }

  class MySon:MyParent

  {

  public override void fun()

  {

  Console.WriteLine(“Son”);

  }

  }

  public class MyTest

  {

  public static void Main(string[] args)

  {

  InFace inf=new MySon();

  inf.fun();

  Console.Read();

  }

  }

  結果:Son

  (7)

  interface InFace

  {

  void fun();

  }

  abstract class MyParent:InFace

  {

  public void fun()

  {

  Console.WriteLine(“Parent”);

  }

  }

  class MySon:MyParent

  {

  public override void fun()

  {

  Console.WriteLine(“Son”);

  }

  }

  public class MyTest

  {

  public static void Main(string[] args)

  {

  InFace inf=new MySon();

  inf.fun();

  Console.Read();

  }

  }

  結果:語(yǔ)法錯誤: 無(wú)法重寫(xiě)繼承成員“ConsoleApplication6.MyParent.fun()”,因為它未標記為 virtual、abstract 或 override

  8、在.NET中有自動(dòng)的垃圾回收機制,但是我們也可以顯示聲明類(lèi)的析構函數,請寫(xiě)出下列程序的輸出結果:像這個(gè)程序一樣我們顯示聲明類(lèi)的析構函數,會(huì )有什么問(wèn)題出現?

  class Parent

  {

  public Parent()

  {

  Console.WriteLine(“Parent”);

  }

  ~Parent()

  {

  Console.WriteLine(“Delete Parent”);

  }

  }

  class Son:Parent

  {

  public Son():base()

  {

  Console.WriteLine(“Son”);

  }

  ~Son()

  {

  Console.WriteLine(“Delete Son”);

  }

  }

  public class MyTest

  {

  public static void Main(string[] args)

  {

  Son son=new Son();

  }

  }

  結果:Parent

  Son

  Delete Son

  Delete Parent

  9、 按值傳遞和按引用傳遞各有什么特點(diǎn)。它們有什么區別?

  答:在按值傳遞中,在被調方法中對變量所做的修改不會(huì )影響主調方法中的變量。

  在按引用傳遞中,在被調方法中對變量所做的修改會(huì )反映到主調方法中的變量。

  10、 寫(xiě)出下更程序的輸出結果:

  (1)public class MyTest

  {

  public static void Main(string[] args)

  {

  int i=10;

  fun(i);

  Console.WriteLine(“i=”+i);

  Console.Read();

  }

  public static int fun(int a)

  {

  a++;

  Console.WriteLine(“a=”+a);

  return a;

  }

  }

  結果:a=11

  i=10

  (2)

  public static void Main(string[] args)

  {

  int i=10;

  fun(out i);

  Console.WriteLine(“i=”+i);

  Console.Read();

  }

  public static int fun(out int a)

  {

  a++;

  Console.WriteLine(“a=”+a);

  return a;

  }

  結果:語(yǔ)法錯誤: 控制離開(kāi)當前方法之前必須對輸出參數“a”賦值

  使用了未賦值的局部變量“a”

  (3)

  public class MyTest

  {

  public static void Main(string[] args)

  {

  int i=10;

  fun(out i);

  Console.WriteLine(“i=”+i);

  Console.Read();

  }

  public static int fun(out int a)

  {

  a=12;

  a++;

  Console.WriteLine(“a=”+a);

  return a;

  }

  }

  結果:a=13

  i=13

  (5)

  public class MyTest

  {

  public static void Main(string[] args)

  {

  int i=10;

  fun(ref i);

  Console.WriteLine(“i=”+i);

  Console.Read();

  }

  public static int fun(ref int a)

  {

  a++;

  Console.WriteLine(“a=”+a);

  return a;

  }

  }

  結果:a=11

  i=11

  附關(guān)于out參數的相關(guān)知識點(diǎn):

  必須被賦值。

  方法參數上的 out 方法參數關(guān)鍵字使方法引用傳遞到方法的同一個(gè)變量。當控制傳遞回調用方法時(shí),在方法中對參數所做的任何更改都將反映在該變量中。

  當希望方法返回多個(gè)值時(shí),聲明 out 方法非常有用。使用 out 參數的方法仍然可以返回一個(gè)值。一個(gè)方法可以有一個(gè)以上的 out 參數。

  若要使用 out 參數,必須將參數作為 out 參數顯式傳遞到方法。out 參數的值不會(huì )傳遞到 out 參數。

  不必初始化作為 out 參數傳遞的變量。然而,必須在方法返回之前為 out 參數賦值。

  屬性不是變量,不能作為 out 參數傳遞。

  如果兩個(gè)方法的聲明僅在 out 的使用方面不同,則會(huì )發(fā)生重載。不過(guò),無(wú)法定義僅在 ref 和 out 方面不同的重載。例如,以下重載聲明是有效的:

  class MyClass

  {

  public void MyMethod(int i) {i = 10;}

  public void MyMethod(out int i) {i = 10;}

  }

  而以下重載聲明是無(wú)效的:

  class MyClass

  {

  public void MyMethod(out int i) {i = 10;}

  public void MyMethod(ref int i) {i = 10;}

  }

  與所有的 out 參數一樣,在使用數組類(lèi)型的 out 參數前必須先為其賦值,即必須由接受方為其賦值。例如:

  public static void MyMethod(out int[] arr)

  {

  arr = new int[10]; // definite assignment of arr

  }

  與所有的 ref 參數一樣,數組類(lèi)型的 ref 參數必須由調用方明確賦值。因此不需要由接受方明確賦值?梢詫到M類(lèi)型的 ref 參數更改為調用的結果。例如,可以為數組賦以 null 值,或將其初始化為另一個(gè)數組。例如:

  public static void MyMethod(ref int[] arr)

  {

  arr = new int[10]; // arr initialized to a different array

  }

  下面的兩個(gè)示例說(shuō)明 out 和 ref 在將數組傳遞給方法上的用法差異。

  示例 1

  在此例中,在調用方(Main 方法)中聲明數組 myArray,并在 FillArray 方法中初始化此數組。然后將數組元素返回調用方并顯示。

  // cs_array_ref_and_out.cs

  using System;

  class TestOut

  {

  static public void FillArray(out int[] myArray)

  {

  // Initialize the array:

  myArray = new int[5] {1, 2, 3, 4, 5};

  }

  static public void Main()

  {

  int[] myArray; // Initialization is not required

  // Pass the array to the callee using out:

  FillArray(out myArray);

  // Display the array elements:

  Console.WriteLine(“Array elements are:”);

  for (int i=0; i < myArray.Length; i++)

  Console.WriteLine(myArray[i]);

  }

  }

  輸出

  Array elements are:

  1

  2

  3

  4

  5

  示例 2

  在此例中,在調用方(Main 方法)中初始化數組 myArray,并通過(guò)使用 ref 參數將其傳遞給 FillArray 方法。在 FillArray 方法中更新某些數組元素。然后將數組元素返回調用方并顯示。

  // cs_array_ref_and_out2.cs

  using System;

  class TestRef

  {

  public static void FillArray(ref int[] arr)

  {

  // Create the array on demand:

  if (arr == null)

  arr = new int[10];

  // Otherwise fill the array:

  arr[0] = 123;

  arr[4] = 1024;

  }

  static public void Main ()

  {

  // Initialize the array:

  int[] myArray = {1,2,3,4,5};

  // Pass the array using ref:

  FillArray(ref myArray);

  // Display the updated array:

  Console.WriteLine(“Array elements are:”);

  for (int i = 0; i < myArray.Length; i++)

  Console.WriteLine(myArray[i]);

  }

  }

  輸出

  Array elements are:

  123

  2

  3

  4

  1024

  10、 怎樣從彈出窗口中刷新主窗口?

  private void button1_Click(object sender, System.EventArgs e)

  {

  Form2 frm = new Form2();

  try

  {

  frm.ShowDialog(this);

  }

  finally

  {

  frm.Dispose();

  }

  }

  private void button1_Click(object sender, System.EventArgs e)

  {

  Form parent = this.Owner as Form;

  if(parent != null)

  parent.Refresh();

  }

  11、 Attribute的參數?

  答:Attribute類(lèi)的構造函數沒(méi)有參數,

  AttributeUsageAttribute類(lèi)指定另一特性類(lèi)的用法,有一個(gè)參數

  public AttributeUsageAttribute( AttributeTargets validOn);

  12、 怎樣確定垃圾確實(shí)被回收了,調用了supressfinalize或collect方法就一定銷(xiāo)毀了對象嗎?顯示調用了析構方法就一定銷(xiāo)毀了對象嗎?

  答:垃圾回收 GC 類(lèi)提供 GC.Collect 方法,您可以使用該方法讓?xiě)贸绦蛟谝欢ǔ潭壬现苯涌刂评厥掌,這就是強制垃圾回收。

  Finalize 方法和析構函數如何允許對象在垃圾回收器自動(dòng)回收對象的內存之前執行必要的清理操作。

  對于您的應用程序創(chuàng )建的大多數對象,可以依靠 .NET Framework 的垃圾回收器隱式地執行所有必要的內存管理任務(wù)。但是,在您創(chuàng )建封裝非托管資源的對象時(shí),當您在應用程序中使用完這些非托管資源之后,您必須顯式地釋放它們。最常見(jiàn)的一類(lèi)非托管資源就是包裝操作系統資源的對象,例如文件、窗口或網(wǎng)絡(luò )連接。雖然垃圾回收器可以跟蹤封裝非托管資源的對象的生存期,但它不了解具體如何清理這些資源。對于這些類(lèi)型的對象,.NET Framework 提供 Object.Finalize 方法,它允許對象在垃圾回收器回收該對象使用的內存時(shí)適當清理其非托管資源。默認情況下,Finalize 方法不執行任何操作。如果您要讓垃圾回收器在回收對象的內存之前對對象執行清理操作,您必須在類(lèi)中重寫(xiě) Finalize 方法。當使用 C# 和 C++ 的托管擴展以外的編程語(yǔ)言進(jìn)行開(kāi)發(fā)時(shí),您可以實(shí)現 Finalize 方法。C# 和托管擴展提供析構函數作為編寫(xiě)終止代碼的簡(jiǎn)化機制。析構函數自動(dòng)生成 Finalize 方法和對基類(lèi)的 Finalize 方法的調用。在 C# 和托管擴展編程語(yǔ)言中,您必須為終止代碼使用析構函數語(yǔ)法

  

【新蛋科技.net工程方面的筆試題】相關(guān)文章:

.net面試題07-25

NET筆試題目11-06

.NET高頻筆試題11-16

網(wǎng)宿科技研發(fā)類(lèi)2011筆試題07-18

ASP.NET筆試題小匯總02-12

NIIT .Net方向考試筆試題01-21

綠盟科技2013全國統一筆試題12-10

ASP.NET的一套筆試題02-12

迅雷2011.10.21筆試題08-10

中興2015筆試題08-02

一级日韩免费大片,亚洲一区二区三区高清,性欧美乱妇高清come,久久婷婷国产麻豆91天堂,亚洲av无码a片在线观看