2011年11月15日

CallBackMethod

摘要: using System;namespace ConsoleApplication1{ class CallBackMethod { private delegate string DelegateName(int Num, out int Num2); private static string MethodName11(int Num, out int Num2) { Num2 = Num; return "HelloWorld"; } //异步完成时,执行的方法(回调方法),此方法只能有IAsyncResult一个参数,但是该参数几乎万能,可以传递object pri 阅读全文

posted @ 2011-11-15 22:29 breakpoint 阅读(191) 评论(0) 推荐(0)

AnonymousDelegate_Sample

摘要: //Copyright (C) Microsoft Corporation. All rights reserved.using System;using System.Collections.Generic;using System.Text;namespace AnonymousDelegate_Sample{ // Define the delegate method. delegate decimal CalculateBonus(decimal sales); // Define an Employee type. class Employee { public string nam 阅读全文

posted @ 2011-11-15 22:28 breakpoint 阅读(128) 评论(0) 推荐(0)

AttributesSample.

摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Reflection;namespace ConsoleApplication1{ /// <summary> /// AttributeTargets.Class表示我们自定义的属性只能用于类上。 /// </summary> [AttributeUsage(AttributeTargets.Class)] public class MyCustomAttribute : Attr 阅读全文

posted @ 2011-11-15 22:28 breakpoint 阅读(99) 评论(0) 推荐(0)

IsTestedAttribute

摘要: //Copyright (C) Microsoft Corporation. All rights reserved.// AttributesTutorial.cs// This example shows the use of class and method attributes.using System;using System.Reflection;using System.Collections;// The IsTested class is a user-defined custom attribute class.// It can be applied to any dec 阅读全文

posted @ 2011-11-15 22:28 breakpoint 阅读(116) 评论(0) 推荐(0)

AbstractClass

摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ abstract class AbstractClass //抽象类可以包括抽象方法,这是普通类所不能的 ,抽象方法只能声明于抽象类中,且不包含任何实现,派生类必须覆盖它们。 //好的接口定义应该是具有专一功能性的,而不是多功能的,否则造成接口污染。如果一个类只是实现了这个接口的中一个功能,而不得不去实现接口中的其他方法,就叫接口污染 { //当在差异较大的对象间寻求功能 阅读全文

posted @ 2011-11-15 22:27 breakpoint 阅读(220) 评论(0) 推荐(0)

EchoServer

摘要: using System;using System.Net.Sockets;using System.IO;using System.Net;namespace ConsoleApplication1{ class EchoServer { public static void Main11() { // TcpListener监听端口1234 IPAddress ipAd = IPAddress.Parse("192.168.1.158"); TcpListener tcpListener = new TcpListener(ipAd,5555); tcpListener 阅读全文

posted @ 2011-11-15 22:26 breakpoint 阅读(151) 评论(0) 推荐(0)

DateClient

摘要: class DateClient { //the needed member feilds private TcpClient tcpc; private string name; private int port = 4554; private bool readData = false; public DateClient(string name) { //a label tryagain: this.name = name; try { //connect to the "localhost" at the give port //if you have some o 阅读全文

posted @ 2011-11-15 22:23 breakpoint 阅读(164) 评论(0) 推荐(0)

DateServer

摘要: class DateServer { private TcpListener myListener; private int port = 8001; public DateServer() { try { //start listing on the given port myListener = new TcpListener(port); myListener.Start(); Console.WriteLine("Server Ready - Listining for new Connections ..."); //start the thread which 阅读全文

posted @ 2011-11-15 22:21 breakpoint 阅读(115) 评论(0) 推荐(0)

导航