1 / 2
文档名称:

编程.doc

格式:doc   页数:2页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

编程.doc

上传人:yzhqw888 2016/7/12 文件大小:0 KB

下载得到文件列表

编程.doc

相关文档

文档介绍

文档介绍:编程: 1、定义并实现一个接口: interface IDimensions { float getLength(); float getWidth(); } class Box : IDimensions { float lengthInches; float widthInches; Box( float length, float width) { lengthInches = length; widthInches = width; } float IDimensions .getLength() { return lengthInches; } float IDimensions .getWidth() { return widthInches; } static void Main() { Box box1 = new Box (, ); IDimensions dimensions =( IDimensions )box1; System. Console .WriteLine( "Len gth: {0}" , ()); System. Console .WriteLine( "Wid th: {0}" , ()); }}2、委托: public delegate void Del(string message); // Create a method for a delegate. public static void DelegateMethod(string message) { (m essage); } // Instantiate the delegate. Del handler = DelegateMethod; // Call the delegate. handler("Hello World"); public void MethodWithCallback(int param1, int param2, Del callback) { callback("The number is: "+ (param1 + param2).ToString()); } MethodWithCallback(1, 2, handler); 3、异步调用 using System; using ; namespace AsyncDemo { class AsyncDemo {[ STAThread ] static void Main( string [] args) { AsyncDemo ad= new AsyncDemo (); (); Console .Read(); } string LongRunningMethod( int iCallTime, out int iExecThread) { Thread .Sleep(iCallTime); iExecThread = AppDomain .GetCurrentThreadId() ; return "MyCallTime was "+