易截截图软件、单文件、免安装、纯绿色、仅160KB

C#面试笔试小贴士 2

对于多态,还必需提一个C#中的关键字:new。前面提到,对于virtual方法,JIT会确定实例的实际类型然后决定调用什么方法。但是如果派生类中new关键字修饰方法,则它向CLR澄清此派生类中的方法与基类中的方法毫无关系,以下代码最终调用是基类的introduce方法:
Code
class Program
{
    static void Main(string[] args)
     {
         Sample1.M1(new OrdinaryPeople("ZhangSan"));
         Sample1.M1(new Superman("Hancock"));
         Console.Read();
     }
}
class Sample1
{
    public static void M1(Person p)
     {
         p.Introdce();
     }
}
class Person
{
    protected string mName;
    public Person(string pName)
     {
        this.mName = pName;
     }
    public virtual void Introdce()
     {
         Console.WriteLine("Hello,I am " + this.mName);
     }
}
class OrdinaryPeople : Person
{
    public OrdinaryPeople(string pName)
         : base(pName)
     {
     }
    public new void Introdce()
     {
         Console.WriteLine("Hello,I am an ordinary person," + this.mName);
     }
}
class Superman : Person
{
    public Superman(string pName)
         : base(pName)
     {
     }
    public new void Introdce()
   &


相关文档:

c#线程

c#中写一个多线程应用是非常简单的,本章将介绍如何在c#种开发多线程程序。在.net中线程是由System.Threading 名字空间所定义的。所以你必须包含这个名字空间。
using System.Threading;
开始一个线程
System.Threading 名字空间的线程类描述了一个线程对象,通过使用类对象,你可以创建、删除、停止及恢复一个线程。 ......

C#扫描计算机端口

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace PortScanner
{
class Program
{
 //已扫描端口数目
 internal static int scannedCount = 0;
 //正在运行的线程数目
 internal static int ru ......

C#清除页面缓存

C#清除页面缓存
    private void SetPageNoCache()
        {
            Response.Buffer = true;
            Response.ExpiresAbsolute = Sy ......

利用WM_COPYDATA在应用程序间传递数据(C#)

利用WM_COPYDATA在应用程序间传递数据很简单,开销也小
一、传递数据部分
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace ThreeTorches
{
    public struct Copydatastru ......

C#面试笔试小贴士 1

ü   ref、out、与params
应该来说这三个关键在一般的编码过程中还是会不时涉及到的,所以不算什么“冷僻”的概念。有关三个参数修饰符的解释如下:
Ref:ref关键字让一个值类型的输入参数按引用传递。实际上,对于引用类型的参数,是否使用ref关键字,差别微乎其微。有一个例外是String类型的参 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号