1.在.NET(C#)中需要进行哪些操作才能使用自定义类库。假设,自定义类库的动态连接库文件为CustListBox.dll,类库的命名空间是Custom。
2.列出3中连接字符串的方法,并分析比较其效率.
3.在.net中如何取消一个窗体的关闭.
4.C#代码实现,确保windows程序只有一个实例(instance).

解决方案 »

  1.   

    添加程序集的引用;
    添加引用的时候要选择浏览,然后选择你的CustListBox.dll文件;这样就可以了;
      

  2.   

    添加程序集的引用,然后using Custom;
      

  3.   

    列出3中连接字符串的方fa:
    1.string a,b;
    s =a +b;
    2.stringbuilder s =new stringbuilder()
    s.Append(a);
    s.Append(b);
      

  4.   

    3.在它的close事件中
    return;
      

  5.   

    4.使用process
    如果windows process大于1
    然后kill,直到只剩下一个
      

  6.   

    主要应用System.Diagnostics名字空间中的Process类来实现,思路,我们在运行程序前,查找进程中是否有同名的进程,同时运行位置也相同程,如是没有运行该程序,如果有,就将同名的同位置的程序窗口置前.
    主要代码:
    [C#]
    public static Process RunningInstance() 

    Process current = Process.GetCurrentProcess(); 
    Process[] processes = Process.GetProcessesByName (current.ProcessName); 
    //查找相同名称的进程 
    foreach (Process process in processes) 

    //忽略当前进程 
    if (process.Id != current.Id) 

    //确认相同进程的程序运行位置是否一样. 
    if (Assembly.GetExecutingAssembly().Location.Replace("/", "\\") == current.MainModule.FileName) 

    //Return the other process instance. 
    return process; 



    //No other instance was found, return null. 
    return null; 
    }