interface IMyExample {
string this[int index] { get ; set ; }
event EventHandler Even ;
void Find(int value) ;
string Point { get ; set ; }
}
public delegate void EventHandler(object sender, Event e) ;
interface IControl {
void Paint( ) ;
}
interface ITextBox: IControl {
void SetText(string text) ;
}
interface IListBox: IControl {
void SetItems(string[] items) ;
}
interface IComboBox: ITextBox, IListBox { }
interface IDataBound {
void Bind(Binder b) ;
}
public class EditBox: Control, IControl, IDataBound {
public void Paint( ) ;
public void Bind(Binder b) {...}
}
[attributes] [modifiers] interface identifier [:base-list] {interface-body}[;]
interface IShape {
void Draw ( ) ;
}
interface INewInterface: IParent1, IParent2 { }
interface IShape { public void Draw( ) ; }
interface IControl {
void Paint( ) ;
}
interface IInterface: IBase1, IBase2 {
void Method1( ) ;
void Method2( ) ;
}
class Class: Iface, Iface {
// class 成员。
// http://www.cnblogs.com/roucheng/
}
class ClassA: BaseClass, Iface1, Iface2 {
// class成员。
}
interface IFace {
void ShowMyFace( ) ;
}
class CFace:IFace
{
public void ShowMyFace( ) {
Console.WriteLine(" implementation " ) ;
}
}
interface IControl {
void Paint( ) ;
}
interface ITextBox: IControl {
void SetText(string text) ;
}
interface IListBox: IControl {
void SetItems(string[] items) ;
}
interface IComboBox: ITextBox, IListBox { }
interface-body:
{ interface-member-declarationsopt }
interface IMyTest{
string this[int index] { get; set; }
event EventHandler E ;
void F(int value) ;
string P { get; set; }
}
public delegate void EventHandler(object sender, EventArgs e) ;
public delegate void StringListEvent(IStringList sender);
public interface IStringList
{
void Add(string s);
int Count { get; }
event StringListEvent Changed;
string this[int index] { get; set; }
}
interface IControl {
void Paint( ) ;
}
interface ITextBox: IControl {
void GetText(string text) ;
}
namespace System
{
public interface IDataTable {
object Clone( ) ;
}
}
using System ;
interface ISequence {
int Count { get; set; }
}
interface IRing {
void Count(int i) ;
}
// http://www.cnblogs.com/roucheng/
interface IRingSequence: ISequence, IRing { }
class CTest {
void Test(IRingSequence rs) {
//rs.Count() ; 错误, Count 有二义性
//rs.Count = ; 错误, Count 有二义性
((ISequence)rs).Count = ; // 正确
((IRing)rs).Count() ; // 正确调用IRing.Count
}
}
using System ;
interface IInteger {
void Add(int i) ;
}
interface IDouble {
void Add(double d) ;
}
interface INumber: IInteger, IDouble {}
class CMyTest {
void Test(INumber Num) {
// Num.Add() ; 错误
Num.Add(.) ; // 正确
((IInteger)n).Add() ; // 正确
((IDouble)n).Add() ; // 正确
}
}
interface IBase {
void FWay(int i) ;
}
interface ILeft: IBase {
new void FWay (int i) ;
}
interface IRight: IBase
{ void G( ) ; }
interface IDerived: ILeft, IRight { }
class CTest {
void Test(IDerived d) {
d. FWay () ; // 调用ILeft. FWay http://www.cnblogs.com/roucheng/
((IBase)d). FWay () ; // 调用IBase. FWay
((ILeft)d). FWay () ; // 调用ILeft. FWay
((IRight)d). FWay () ; // 调用IBase. FWay
}
}
using System ;
interface ISequence {
object Add( ) ;
}
interface ISequence {
object Add( ) ;
}
interface IRing {
int Insert(object obj) ;
}
class RingSequence: ISequence, IRing
{
public object Add( ) {…}
public int Insert(object obj) {…}
}
using System ;
interface IControl {
void Paint( );
}
interface ITextBox: IControl {
void SetText(string text);
}
interface IListBox: IControl {
void SetItems(string[] items);
}
interface IComboBox: ITextBox, IListBox { }
interface IDataBound {
void Bind(Binder b);
}
public class EditBox: Control, IControl, IDataBound {
public void Paint( );
public void Bind(Binder b) {...}
}
public class EditBox: IControl, IDataBound {
void IControl.Paint( ) {...}
void IDataBound.Bind(Binder b) {...}
}
class Test {
static void Main( ) {
EditBox editbox = new EditBox( );
editbox.Paint( ); //错误: EditBox 没有Paint 事件
IControl control = editbox;
control.Paint( ); // 调用 EditBox的Paint事件
}
}
public class EditBox: IControl, IDataBound {
void IControl.Paint( ) {…}
void IDataBound.Bind(Binder b) {…}
}
class CTest {
static void Main( ) {
EditBox editbox = new EditBox( ) ;
editbox.Paint( ) ; //错误:不同的方法
IControl control = editbox;
control.Paint( ) ; //调用 EditBox的Paint方法
}
}
using System ;
interface ICloneable {
object Clone( ) ;
}
interface IComparable {
int CompareTo(object other) ;
}
class ListEntry: ICloneable, IComparable {
object ICloneable.Clone( ) {…}
int IComparable.CompareTo(object other) {…}
}
class Shape: ICloneable {
object ICloneable.Clone( ) {…}
int IComparable.CompareTo(object other) {…}
}
class Shape: ICloneable
{
object ICloneable.Clone( ) {…}
}
class Ellipse: Shape
{
object ICloneable.Clone( ) {…}
}
using System ;
interface IControl
{
void Paint( ) ;
}
interface ITextBox: IControl
{
void SetText(string text) ;
}
class TextBox: ITextBox
{
void IControl.Paint( ) {…}
void ITextBox.SetText(string text) {…}
}
interface IEnglishDimensions {
float Length ( ) ;
float Width ( ) ;
}
interface IMetricDimensions {
float Length ( ) ;
float Width ( ) ;
}
class Box : IEnglishDimensions, IMetricDimensions {
float lengthInches ;
float widthInches ;
public Box(float length, float width) {
lengthInches = length ;
widthInches = width ;
}
float IEnglishDimensions.Length( ) {
return lengthInches ;
}
float IEnglishDimensions.Width( ) {
return widthInches ;
}
float IMetricDimensions.Length( ) {
return lengthInches * .f ;
}
float IMetricDimensions.Width( ) {
return widthInches * .f ;
}
public static void Main( ) {
//定义一个实类对象 "myBox"::
Box myBox = new Box(.f, .f);
// 定义一个接口" eDimensions"::
IEnglishDimensions eDimensions = (IEnglishDimensions) myBox;
IMetricDimensions mDimensions = (IMetricDimensions) myBox;
// 输出:
System.Console.WriteLine(" Length(in): {}", eDimensions.Length( ));
System.Console.WriteLine(" Width (in): {}", eDimensions.Width( ));
System.Console.WriteLine(" Length(cm): {}", mDimensions.Length( ));
System.Console.WriteLine(" Width (cm): {}", mDimensions.Width( ));
}
}
public float Length( ) {
return lengthInches ;
}
public float Width( ){
return widthInches;
}
float IMetricDimensions.Length( ) {
return lengthInches * .f ;
}
float IMetricDimensions.Width( ) {
return widthInches * .f ;
}
System.Console.WriteLine("Length(in): {0}", myBox.Length( )) ;
System.Console.WriteLine("Width (in): {0}", myBox.Width( )) ;
System.Console.WriteLine("Length(cm): {0}", mDimensions.Length( )) ;
System.Console.WriteLine("Width (cm): {0}", mDimensions.Width( )) ;
using System ;
interface IControl {
void Paint( ) ;
}
interface ITextBox: IControl {
void SetText(string text) ;
}
interface IListBox: IControl {
void SetItems(string[] items) ;
}
interface IComboBox: ITextBox, IListBox { }
interface IControl {
void Paint( );
}
class Control: IControl {
public void Paint( ) {...}
}
class TextBox: Control {
new public void Paint( ) {...}
}
Control c = new Control( ) ; TextBox t = new TextBox( ) ; IControl ic = c ; IControl it = t ; c.Paint( ) ; // 影响Control.Paint( ) ; t.Paint( ) ; // 影响TextBox.Paint( ) ; ic.Paint( ) ; // 影响Control.Paint( ) ; it.Paint( ) ; // 影响Control.Paint( ) ;
interface IControl {
void Paint( ) ;
}
class Control: IControl {
public virtual void Paint( ) {...}
}
class TextBox: Control {
public override void Paint( ) {...}
}
Control c = new Control( ) ; TextBox t = new TextBox( ) ; IControl ic = c ; IControl it = t ; c.Paint( ) ; // 影响Control.Paint( ); t.Paint( ) ; // 影响TextBox.Paint( ); ic.Paint( ) ; // 影响Control.Paint( ); it.Paint( ) ; // 影响TextBox.Paint( );
interface IControl {
void Paint( ) ;
}
class Control: IControl {
void IControl.Paint( ) { PaintControl( ); }
protected virtual void PaintControl( ) {...}
}
class TextBox: Control {
protected override void PaintControl( ) {...}
}
interface IControl {
void Paint( ) ;
class Control: IControl
void IControl.Paint( ) {…}
class MyControl: Control, IControl
public void Paint( ) {}
}
using System ;
interface IMethods {
void F( ) ;
void G( ) ;
void H( ) ;
void I( ) ;
}
class Base: IMethods {
void IMethods.F( ) { }
void IMethods.G( ) { }
public void H( ) { }
public void I( ) { }
}
class Derived: Base, IMethods {
public void F( ) { }
void IMethods.H( ) { }
}
using System ;
interface IBase {
void F( ) ;
}
interface IDerived: IBase {
void G( ) ;
}
class C: IDerived {
void IBase.F( ) {
//对F 进行实现的代码…
}
void IDerived.G( ) {
//对G 进行实现的代码…
}
}
class D: C, IDerived {
public void F( ) {
//对F 进行实现的代码…
}
public void G( ) {
//对G 进行实现的代码… http://www.cnblogs.com/roucheng/
}
}
interface Interface1 {
void F( ) ;
}
class Class1 {
public void F( ) { }
public void G( ) { }
}
class Class2: Class1, Interface1 {
new public void G( ) {}
}
interface ICloneable {
object Clone( ) ;
}
class C: ICloneable {
object ICloneable.Clone( ) {…}
public object Clone( ) {…}
}
interface IControl {
void Paint( ) ;
}
interface IForm {
void Paint( ) ;
}
class Page: IControl, IForm {
public void Paint( ) {…}
}
interface IControl {
void Paint( ) ;
}
interface IForm {
void Paint( ) ;
}
class Page: IControl, IForm {
public void IControl.Paint( ) {
//具体的接口实现代码
}
public void IForm.Paint( ) {
//具体的接口实现代码 http://roucheng.cnblogs.com/
}
}
interface IBase {
int P { get; }
}
interface IDerived: IBase {
new int P( ) ;
}
class C: IDerived {
int IBase.P
get
{ //具体的接口实现代码 }
int IDerived.P( ){
//具体的接口实现代码 }
}
class C: IDerived {
int IBase.P
get {//具体的接口实现代码}
public int P( ){
//具体的接口实现代码 }
}
class C: IDerived{
public int P
get {//具体的接口实现代码}
int IDerived.P( ){
//具体的接口实现代码}
}
using System ;
interface IControl {
void Paint( ) ;
interface ITextBox: IControl {
void SetText(string text) ;
}
interface IListBox: IControl {
void SetItems(string[] items) ;
}
class ComboBox: IControl, ITextBox, IListBox {
void IControl.Paint( ) {…}
void ITextBox.SetText(string text) {…}
void IListBox.SetItems(string[] items) {…}
}
// 声明一个COM类 FilgraphManager
[ComImport, Guid("E436EBB3-524F-11CE-9F53-0020AF0BA770")]
class FilgraphManager
{ }
class MainClass
{
public static void Main()
{
FilgraphManager filg = new FilgraphManager();
}
}
using System.Runtime.InteropServices;
// 声明一个COM接口 IMediaControl
[Guid("AB-AD-CE-BA-AFBA"),
InterfaceType(ComInterfaceType.InterfaceIsDual)]
interface IMediaControl // 这里不能列出任何基接口
{
void Run();
void Pause();
void Stop();
void GetState( [In] int msTimeout, [Out] out int pfs);
void RenderFile(
[In, MarshalAs(UnmanagedType.BStr)] string strFilename);
void AddSourceFilter(
[In, MarshalAs(UnmanagedType.BStr)] string strFilename,
[Out, MarshalAs(UnmanagedType.Interface)] out object ppUnk);
[return : MarshalAs(UnmanagedType.Interface)]
object FilterCollection();
[return : MarshalAs(UnmanagedType.Interface)]
object RegFilterCollection();
void StopWhenReady();
}
using System;
using System.Runtime.InteropServices;
namespace QuartzTypeLib
{
//声明一个COM接口 IMediaControl,此接口来源于媒体播放机COM类
[Guid("56A868B1-0AD4-11CE-B03A-0020AF0BA770"),
InterfaceType(ComInterfaceType.InterfaceIsDual)]
interface IMediaControl
{ //列出接口成员
void Run();
void Pause();
void Stop();
void GetState( [In] int msTimeout, [Out] out int pfs);
void RenderFile(
[In, MarshalAs(UnmanagedType.BStr)] string strFilename);
void AddSourceFilter(
[In, MarshalAs(UnmanagedType.BStr)] string strFilename,
[Out, MarshalAs(UnmanagedType.Interface)]
out object ppUnk);
[return: MarshalAs(UnmanagedType.Interface)]
object FilterCollection();
[return: MarshalAs(UnmanagedType.Interface)]
object RegFilterCollection();
void StopWhenReady();
}
//声明一个COM类:
[ComImport, Guid("E436EBB3-524F-11CE-9F53-0020AF0BA770")]
class FilgraphManager //此类不能再继承其它基类或接口
{
//这里不能有任何代码 ,系统自动增加一个缺省的构造函数
}
}
class MainClass
{
public static void Main(string[] args)
{
//命令行参数:
if (args.Length != 1)
{
DisplayUsage();
return;
}
String filename = args[0];
if (filename.Equals("/?"))
{
DisplayUsage();
return;
}
// 声明FilgraphManager的实类对象:
QuartzTypeLib.FilgraphManager graphManager =new QuartzTypeLib.FilgraphManager();
//声明IMediaControl的实类对象::
QuartzTypeLib.IMediaControl mc =(QuartzTypeLib.IMediaControl)graphManager;
// 调用COM的方法:
mc.RenderFile(filename);
//运行文件.
mc.Run();
//暂借停.
Console.WriteLine("Press Enter to continue.");
Console.ReadLine();
}
private static void DisplayUsage()
{ // 显示
Console.WriteLine("媒体播放机: 播放 AVI 文件.");
Console.WriteLine("使用方法: VIDEOPLAYER.EXE 文件名");
}
}
namespace System.Runtime.InteropServices
{
[AttributeUsage(AttributeTargets.Method)]
public class DllImportAttribute: System.Attribute
{
public DllImportAttribute(string dllName) {...}
public CallingConvention CallingConvention;
public CharSet CharSet;
public string EntryPoint;
public bool ExactSpelling;
public bool PreserveSig;
public bool SetLastError;
public string Value { get {...} }
}
}
using System;
using System.Runtime.InteropServices;
class MainApp
{ //通过DllImport引用user.dll类。MessageBox来自于user.dll类
[DllImport("user.dll", EntryPoint="MessageBox")]
public static extern int MessageBox(int hWnd, String strMessage, String strCaption, uint uiType);
public static void Main()
{
MessageBox( , "您好,这是 PInvoke!", ".NET", );
}
}
interface IMethods {
void F();
void G();
}
abstract class C: IMethods
{
public abstract void F();
public abstract void G();
}
interface IMethods
{
void F();
void G();
}
abstract class C: IMethods
{
void IMethods.F() { FF(); }
void IMethods.G() { GG(); }
protected abstract void FF();
protected abstract void GG();
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有