zoukankan      html  css  js  c++  java
  • asp.net常见面试题(一)

    1、索引器

     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
     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

     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
     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

     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
     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 公共语言运行时

  • 相关阅读:
    工作总结_JS_1
    工作总结_js
    图片上传_及时显示
    js_截取Url值
    工作总结_sql
    Django项目配置xadmin 无法加载主题切换功能
    pip安装库慢问题解决方法
    Python模块Scrapy导入出错:ImportError: cannot import name xmlrpc_client
    python读取文件解码失败
    pycharm 修改新建文件时的头部模板
  • 原文地址:https://www.cnblogs.com/ruanmou001/p/3753387.html
Copyright © 2011-2022 走看看