下面有个简单的接口示例:using System;
namespace InterfaceTest
{
interface Ipoint{
int x {
get;
set;
}
int y {
get;
set;
}
}
class Mypoint:Ipoint
{ private int myX;
private int myY;
public Mypoint(int x,int y)
{
myX=x;
myY=y; }
public int x{
get{
return myX;
}
set{
myX=value;
}
}
public int y{
get{
return myY;
}
set{
myY=value;
}
}
}
class Class1
{
static void Main(string[] args){
Mypoint p=new Mypoint(2,3);
Console.Write("My point:");
printpoint(p); //想问下这个有什么意思?有什么用?}
private static void printpoint(Ipoint p){
Console.WriteLine("x={0},y={1}",p.x,p.y);
}
}
}例中的 printpoint(p); //想问下这个有什么意思?有什么用?没了它.好像下边的输出不了.虽然是简单问题..希望大家教教!
namespace InterfaceTest
{
interface Ipoint{
int x {
get;
set;
}
int y {
get;
set;
}
}
class Mypoint:Ipoint
{ private int myX;
private int myY;
public Mypoint(int x,int y)
{
myX=x;
myY=y; }
public int x{
get{
return myX;
}
set{
myX=value;
}
}
public int y{
get{
return myY;
}
set{
myY=value;
}
}
}
class Class1
{
static void Main(string[] args){
Mypoint p=new Mypoint(2,3);
Console.Write("My point:");
printpoint(p); //想问下这个有什么意思?有什么用?}
private static void printpoint(Ipoint p){
Console.WriteLine("x={0},y={1}",p.x,p.y);
}
}
}例中的 printpoint(p); //想问下这个有什么意思?有什么用?没了它.好像下边的输出不了.虽然是简单问题..希望大家教教!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货