using System;
using System.Collections.Generic;
using System.Text;namespace Interface
{
public sealed class Program
{
static void Main(string[] args)
{
;
}
} class Point : IFormattable //提示错误
{ public int x, y;
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
public override String ToString()
{
return ToString(null, null);
//return base.ToString();
} public String ToString(String format, IFormattable fp)
{
if (format == null) return String.Format("({0},{1})", x, y); if (format == "x")
return x.ToString();
if (format == "y")
return y.ToString(); throw new FormatException(String.Format("Invalid format string:'{0}'.", format)); }
}
}上述代码总是提示:
错误 1 “Interface.Point”不会实现接口成员“System.IFormattable.ToString(string, System.IFormatProvider)” D:\Program Files\CSharpStudy\Interface\Interface\Program.cs 15 11 Interface
using System.Collections.Generic;
using System.Text;namespace Interface
{
public sealed class Program
{
static void Main(string[] args)
{
;
}
} class Point : IFormattable //提示错误
{ public int x, y;
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
public override String ToString()
{
return ToString(null, null);
//return base.ToString();
} public String ToString(String format, IFormattable fp)
{
if (format == null) return String.Format("({0},{1})", x, y); if (format == "x")
return x.ToString();
if (format == "y")
return y.ToString(); throw new FormatException(String.Format("Invalid format string:'{0}'.", format)); }
}
}上述代码总是提示:
错误 1 “Interface.Point”不会实现接口成员“System.IFormattable.ToString(string, System.IFormatProvider)” D:\Program Files\CSharpStudy\Interface\Interface\Program.cs 15 11 Interface
{
...
}