码迷,mamicode.com
首页 > Web开发 > 详细

asp.net常见面试题(一)

时间:2014-05-28 04:00:03      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:style   c   class   blog   code   tar   

1、索引器

bubuko.com,布布扣
 1 class Player
 2     {
 3         private int[] arr = new int[100];
 4         public int this[int index]
 5         {
 6             get {
 7                 if (index < 10 || index >= 10)
 8                 {
 9                     return 0;
10                 }
11                 else
12                 {
13                     return arr[index];
14                 }
15             }
16             set {
17                 if (!(index < 0 || index >= 100))
18                 {
19                     arr[index] = value;
20                 }
21             }
22         }
23     }
View Code
bubuko.com,布布扣
 1 class Program
 2     {
 3         static void Main(string[] args)
 4         {
 5             Player p = new Player();
 6             p[0] = 100;
 7             p[1] = 101;
 8             Console.WriteLine(p[0]);
 9             Console.ReadKey();
10         }
11     }
View Code

2、应用程序域

把一个程序进程分为各个独立的小进程,各个小进程中相互隔离,互不影响。

demo1

bubuko.com,布布扣
 1 class Player
 2     {
 3         private static int i;
 4         public void SetValue(int a)
 5         {
 6             i = a;
 7         }
 8         public int GetValue()
 9         {
10             return i;
11         }
12     }
View Code
bubuko.com,布布扣
 1 class Program
 2     {
 3         static void Main(string[] args)
 4         {
 5             Player p1 = new Player();
 6             p1.SetValue(5);
 7             Player p2 = new Player();
 8             p2.SetValue(10);
 9             Console.WriteLine(p1.GetValue());
10             Console.WriteLine(p2.GetValue());
11             Console.ReadKey();
12         }
13     }
View Code

demo2

bubuko.com,布布扣
 1 public class Player:MarshalByRefObject
 2     {
 3         private static int i;
 4         public void SetValue(int a)
 5         {
 6             i = a;
 7         }
 8         public int GetValue()
 9         {
10             return i;
11         }
12     }
View Code
bubuko.com,布布扣
 1   private void Form1_Load(object sender, EventArgs e)
 2         {
 3             AppDomain appDomain1 = AppDomain.CreateDomain("domain1");
 4             Player play1 = (Player)appDomain1.CreateInstanceFromAndUnwrap("WindowsFormsApplication1.exe", "WindowsFormsApplication1.Player");
 5             play1.SetValue(5);
 6             AppDomain appDomain2 = AppDomain.CreateDomain("domain2");
 7             Player play2 = (Player)appDomain2.CreateInstanceFromAndUnwrap("WindowsFormsApplication1.exe", "WindowsFormsApplication1.Player");
 8             play2.SetValue(100);
 9             MessageBox.Show(play1.GetValue().ToString());
10             MessageBox.Show(play2.GetValue().ToString()); 
11         }
View Code

3、CTS、CLS、CLR区别

cts:Comment Type System 通用系统类型,int32、int16--->int,String----->string,Boolean---->bool 不同语言变量类型不同,最后在.net上转换后都是同一种形式。

cls:Comment Language Specification 通用语言规范,不同语言语法不同,最后在.net上转换后都是同一种形式。

clr:Comment Language Runtime 公共语言运行时

 

 

asp.net常见面试题(一),布布扣,bubuko.com

asp.net常见面试题(一)

标签:style   c   class   blog   code   tar   

原文地址:http://www.cnblogs.com/ruanmou001/p/3753387.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!