在学校里的功课,我们有这样的例子:字符串格式作为参数?
它告诉我创建一个名为public abstract method
与ToString
字符串格式参数,它返回一个string
。这怎么可能?
我尝试这样做:
public abstract string ToString(String.Format type)
{
return "Some text";
}
但它返回的一些误区:
The type or namespace name 'Format' could not be found (are you missing a using directive or an assembly reference?)
'Shape.ToString(string, Format)' cannot declare a body because it is marked abstract
我怎样才能解决这个问题?
'abstract'方法不能有body ..'public abstract string ToString(String.Format type);'只会有效。 –
连同@BagusTesa所说的参数被命名为格式,但是在图像中是类型'string'。所以这将是'公共抽象字符串ToString(字符串格式);' – Lithium
好努力,但你只是误读spec +1试试 – WhatsThePoint