菜鸟求解!!!

linzhmu 2012-02-15 05:19:10
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
public class TestFrm
{
public void Main()
{
TestFrm f = new TestFrm();
ITest1 t1 = f;
Debug.Print(t1.strPrint1);
ITest2 t2 = f;
Debug.Print(t2.strPrint2);
}
}

public class TestClass : ITest1, ITest2
{
private string _strPrint1 = "Test1";
private string strPrint1 {
get { return _strPrint1; }
set { _strPrint1 = value; }
}

private string _strPrint2 = "Test2";
private string strPrint2 {
get { return _strPrint2; }
set { _strPrint2 = value; }
}
}

public interface ITest1
{
string strPrint1 { get; set; }
}

public interface ITest2
{
string strPrint2 { get; set; }
}



这就是面向接口编程吗????
...全文
92 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
linzhmu 2012-02-15
  • 打赏
  • 举报
回复
各位大哥帮帮忙啊!!!
linzhmu 2012-02-15
  • 打赏
  • 举报
回复
就是把Class封装起来,只有接口对外
ColorfulHouse 2012-02-15
  • 打赏
  • 举报
回复
接口是一个标准,后面的东东按照这个标准来实行
linzhmu 2012-02-15
  • 打赏
  • 举报
回复
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
public class TestFrm
{
public void Main()
{
TestClass f = new TestClass();
ITest1 t1 = f;
Debug.Print(t1.strPrint1);
ITest2 t2 = f;
Debug.Print(t2.strPrint2);
}
}

public class TestClass : ITest1, ITest2
{
private string _strPrint1 = "Test1";
private string strPrint1 {
get { return _strPrint1; }
set { _strPrint1 = value; }
}

private string _strPrint2 = "Test2";
private string strPrint2 {
get { return _strPrint2; }
set { _strPrint2 = value; }
}
}

public interface ITest1
{
string strPrint1 { get; set; }
}

public interface ITest2
{
string strPrint2 { get; set; }
}



刚刚代码贴错了
EnForGrass 2012-02-15
  • 打赏
  • 举报
回复
我没看出来
linzhmu 2012-02-15
  • 打赏
  • 举报
回复
面向接口编程
熙风 2012-02-15
  • 打赏
  • 举报
回复
不是
Lugyedo 2012-02-15
  • 打赏
  • 举报
回复
你的问题是啥?
  • 打赏
  • 举报
回复
恕我愚笨!我只看出来是一个类继承了两个接口

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧