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

  • 相关阅读:
    编写第一个 .NET 微服务
    Docker 基础知识编排在开发机上设置和使用 Kubernetes 环境
    将微服务部署到 Azure Kubernetes 服务 (AKS) 实践
    .NET Task.Run vs Task.Factory.StartNew
    Python上下文管理器
    Python可迭代的对象与迭代器的对比
    开发你的第一个SpringBoot应用
    Flask的Blueprints和Views
    Flask项目发布流程
    长篇大论Python生成器
  • 原文地址:https://www.cnblogs.com/ruanmou001/p/3753387.html
Copyright © 2011-2022 走看看