• 面试题集锦


    GAC和强类型程序集

    /*全称是Global Assembly Cache作用是可以存放一些有很多程序都要用到的公共Assembly,
    例如System.Data、System.Windows.Forms等等。这样,很多程序就可以从GAC里面取得Assembly,
    而不需要再把所有要用到的Assembly都拷贝到应用程序的执行目录下面。
    举例而言,如果没有GAC,那么势必每个WinForm程序的目录下就都要从
    C:\WINDOWS\Microsoft.NET\Framework\vX下面拷贝一份System.Windows.Forms.dll,
    这样显然不如都从GAC里面取用方便,也有利于Assembly的升级和版本控制。 */
    /*
    因为不同的公司可能会开发出有相同名字的程序集来,如果这些程序集都被复制到同一 个相同的目录下,
    最后一个安装的程序集将会代替前面的程序集。这就是著名的Windows “DLL Hell”出现的原因。 
    很明显,简单的用文件名来区分程序集是不够的,CLR需要支持某种机制来唯一的标识一个程序集。
    这就是所谓的强命名程序集。 
    一个强命名程序集包含四个唯一标志程序集的特性:文件名(没有扩展名),版本号,语言文化信息(如果有的话),公有秘钥。
    */

    一些常见题目

    http://topic.csdn.net/u/20090424/13/3bd8df74-3d5f-4b8e-8201-7b7e2a5948e3.html

    中软最新题目

    中软面试题-最新

    写一个函数,当参数N很大的时候,计算下列算式的结果:1-2+3-4+5-6+7-8+…n

    int intResult = 0;
    for(int i = 1;i<=N;i++)
    {
        if(i%2==0)
        {
            intResult -= i;
        }
        else
        {
            intResult += i;
         }
    }

    什么叫应用程序域?什么是受管制的代码?什么是强类型系统?什么是装箱和拆箱?什么是重载?CTS、CLS和CLR分别作何解释

    以运行库为目标的代码称为托管代码。
    装箱就是把值类型转成引用类型,拆箱则反之。
    重载就是指一个方法名同,参数个数不同,返回值可以相同的方法.
    CTS(Common Type System)通用类型系统,CLS(Common Language Specification)公共语言规范,CLR(Common Language Runtime)是通用语言运行时,

    webservice

    Web Services是由企业发布的完成其特定商务需求的在线应用服务,其他公司或应用软件能够通过Internet来访问并使用这项在线服务。
    在构建和使用Web Service时,主要用到以下几个关键的技术和规则:   
    1.XML:描述数据的标准方法.   
    2.SOAP:表示信息交换的协议.   
    3.WSDL:Web服务描述语言. 
    SOAP:简单对象访问协议   
    (SOAP:Simple Object Access Protocol)   
    简单对象访问协议(SOAP)是一种轻量的、简单的、基于 XML 的协议,它被设计成在 WEB 上交换结构化的和固化的信息。

    垃圾回收机制

    NET Framework 的垃圾回收器管理应用程序的内存分配和释放。
    每次您使用 new 运算符创建对象时,运行库都从托管堆为该对象分配内存。
    只要托管堆中有地址空间可用,运行库就会继续为新对象分配空间。
    但是,内存不是无限大的。最终,垃圾回收器必须执行回收以释放一些内存。
    垃圾回收器优化引擎根据正在进行的分配情况确定执行回收的最佳时间。
    当垃圾回收器执行回收时,它检查托管堆中不再被应用程序使用的对象并执行
    必要的操作来回收它们占用的内存。

    程序设计: 猫大叫一声,所有的老鼠都开始逃跑,主人被惊醒。

    委托 参考C#中的委托和事件以及http://xhinker.blog.51cto.com/640011/189657

    委托是一种引用方法的类型。一旦为委托分配了方法,委托将与该方法具有完全相同的行为。
    委托方法的调用可以像其他任何方法一样,具有参数和返回值
    public delegate void CatEventHandler(object sender, myEvent e);
     
        public class Cat
        {
            public event CatEventHandler catMiao;
     
            string name, color;
            public Cat(string name, string color)
            {
                this.name = name;
                this.color = color;
            }
            public string Name { get; set; }
            public string Color { get; set; }
     
            public void Miao()
            {
              System.Console.WriteLine("我是" + name + "花色" + color + "miao~~~~~~~~~~~~~~~~~~~~~~~~~~");
     
                catMiao(this, null);//调用事件方法,订阅了这个事件的方法列表得到执行
            }
        }
        public class Mouse
        {
            Cat cat;
            string name;
            public Mouse(string name, Cat c) { this.name = name; cat = c; 
                cat.catMiao += new CatEventHandler(run);//当前对象订阅事件     
             }
            public string Name { get; set; }
     
            public void run(object sender,myEvent e) {
                System.Console.WriteLine(name+",老鼠开始跑~~~~~~~~~~~~~~~");
     
            }
        }
        public class People
        {
            Cat cat;
            string name;
            public People(string name, Cat c) { this.name = name; cat = c; 
                cat.catMiao += new CatEventHandler(wake); //当前对象订阅事件
            }
            public string Name { get; set; }
     
            public void wake(object sender, myEvent e)
            {
                System.Console.WriteLine(name + ",人被吵醒来了~~~~~~~~~~~~~~~");
            }
        }
        class Cat_Mouse_People
        {
            static void Main(string[] args){
                Cat cat = new Cat("猫扑 ", "yellow");
                Mouse mouse = new Mouse("米老鼠",cat);
                People people = new People("人类",cat);
     
                cat.Miao();
     
                System.Console.ReadKey();
            }
        }

    这也是订阅者模式的.net实现

    简单算法题目

    #region 判断一个字符串是不是回文
            public static bool IsHuiWen(char[] arr)
            {
                int start = 0;
                int end = arr.Length - 1;
     
                while (start <= end)
                {
                    if (arr[start] != arr[end])
                    {
                        return false;
                    }
                    else
                    {
                        start++;
                        end--;
                    }
                }
                return true;
            }
            #endregion

    #region 实现字符串转数字(整数)
            public static int Parse(string str){
                char[] arr = str.ToCharArray();
                int i = 0;
                int result = 0;
                while (i<arr.Length)
                {
                    result = result * 10 + (arr[i] - '0');
                    i++;
                }
                return result;
            }
            public static int tryParse(string str)
            {
                char[] arr = str.ToCharArray();
                int i = 0;
                int result = 0;
                while (i < arr.Length)
                {
                    int temp=arr[i]-'0';
                    if (temp < 0 || temp > 9)
                    {
                        result = -1; break;
                    }
                    result = result * 10 + (arr[i] - '0');
                    i++;
                }
                return result;
            }
            
            #endregion

    #region 请将一个整数数字,分解后放入一个整形数组中,并统计其中每个数出现的重复数量(不能使用Library)
            public static void Count(int num)
            {
                string numstr = num.ToString();
                int[] arr = new int[numstr.Length];
                System.Collections.Generic.Dictionary<int, int> dic = new Dictionary<int, int>();
                for (int i = 0; i < numstr.Length; i++)
                {
                    arr[i] = numstr[i] - '0';
                    if (!dic.ContainsKey(numstr[i] - '0'))
                    {
                        dic[numstr[i] - '0'] = 1;
                    }
                    else
                        dic[numstr[i] - '0'] = dic[numstr[i] - '0'] + 1;
                }
                foreach (KeyValuePair<int, int> kv in dic)
                {
                    Console.WriteLine("{0}出现了{1}次", kv.Key.ToString(), kv.Value.ToString());
                }
            }
            #endregion

    #region 冒泡排序
            public static int[] MPSort(int[] arr){
                for (int i = 0; i < arr.Length-1; i++)
                {
                    for (int j = 0; j < arr.Length-1; j++)
                    {
                        if(arr[j]>arr[j+1]){
                            int temp = arr[j];
                            arr[j] = arr[j + 1];
                            arr[j + 1] = temp;
                        }
                    }
                }
                return arr;
            }
            #endregion

    #region 99乘法表
            public static void jiujiu() {
                for (int i = 1; i < 10; i++)
                {
                    for (int j = 1; j <=i; j++)
                    {
                        Console.Write("{0}*{1}={2}\t",i.ToString(),j.ToString(),(i*j).ToString());
                    }
                    Console.WriteLine();
                }
            }
            #endregion
    #region 已知m和n是已经排序好的数组,从小到大,现在要合并这两个数组内的数到一个数组,仍然要求是从小到大排序
            public static void HeBingArr(int[] a,int [] b) {
                //先concat连接两个数组,去重复,冒泡排序
     
            }
     
            #endregion
            #region 递归求n阶乘
            public static int NJieCheng(int n) {
                if (n < 0)
                    throw new ArgumentOutOfRangeException();
                else
                    return n < 2 ? n : NJieCheng(n - 1) * n;
            }
            
            #endregion
    #region 删除arrayList内小于50的元素
                ArrayList lst = new ArrayList();
                for (int i = 0; i < 10; i++)
                {
                    lst.Add((new Random()).Next(10, 100));
                    System.Threading.Thread.Sleep(10);
                    Console.Write(lst[i].ToString() + "  ");
                    if (i % 9 == 0 && i > 0)
                        Console.WriteLine();
                }
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine();
                for (int j = 0; j < lst.Count; j++)
                {
                    int temp = (int)lst[j];
                    if (temp < 50)
                    { lst.RemoveAt(j); j--; }
                }
     
                for (int k = 0; k < lst.Count; k++)
                {
                    Console.Write(lst[k].ToString() + "   ");
                    if (k % 9 == 0 && k > 0)
                        Console.WriteLine();
                }
                #endregion

    /*类info,把all里面的info按照数组order的顺序排列*/
    public class Info{
           public Info(int id, string msg) {ID = id;Msg = msg;}
           public int ID { get; set; }
           public string Msg { get; set; }
       }
     
    ArrayList all = new ArrayList();
                all.Add(new Info(1, "11"));
                all.Add(new Info(2, "22"));
                all.Add(new Info(3, "33"));
     
    int[] order = new int[] { 3,2,1};
     
                for (int i = 0; i < order.Length;i++ )
                {
                    for (int j = 0; j < all.Count;j++ )
                    {
                        Info info = (Info)all[j];
                        if (info.ID == order[i] && j!=i) {
                            Info info2 = (Info)all[i];
                            all[j] = info2;
                            all[i] = info;
                        }
                    }
                }

    程序题目

    class A{}
        class B:A{
            static B(){Console.WriteLine("hello");}
            public B(){Console.WriteLine("非静态");}
            public override string ToString()
            {return "world";} 
        }
     
    public static void Main(){
                A a = new A();
                Console.WriteLine(a.ToString());
                A a2 = new B();
                Console.WriteLine(a2.ToString());
                B b = new B();
                Console.WriteLine(b.ToString());
                Console.ReadKey();
            }
    /*答案*/
    public static void Main(){
                A a = new A();
                Console.WriteLine(a.ToString());//由于a本身没有重写toString方法,那么调用原生的object的ToString 输出 命名空间.A
                A a2 = new B();//调用static B(),静态成员,在类的初次使用的时候初始化 输出  hello。 然后调用馋鬼构造函数 输出  非静态
                Console.WriteLine(a2.ToString());//输出重写过的ToString  world
                B b = new B();//由于B类以及使用过了,其静态成员虚无再进行初始化,于是输出 非静态
                Console.WriteLine(b.ToString());//输出 world
                Console.ReadKey();
            }
    命名空间.A
    hello
    非静态
    world
    非静态
    world

    LinQ排序

    .           int[] arr = { 2, 4, 10, 5, 6 };
                arr= arr.OrderBy(x => x).ToArray<int>(); //第一种
              //第二种
                var arr2=from x in arr 
                            orderby x descending
                             select x;
  • 相关阅读:
    java_web连接SQL_server详细步骤
    探索需求-设计前的质量之二
    EF三种编程方式详细图文教程(C#+EF)之Code First
    EF三种编程方式详细图文教程(C#+EF)之Model First
    EF三种编程方式详细图文教程(C#+EF)之Database First
    探索需求-设计前的质量之一
    编写有效用例之三
    编写有效用例之二
    golang 环境安装
    golang 命令详解
  • 原文地址:https://www.cnblogs.com/jianjialin/p/1763025.html
Copyright © 2020-2023  润新知