我有一个名为myResult的dataTable,它有两列Process和ParentProcess,我试图把它放到一个Ienumerable类型中,所以我可以用Json.net序列化它.
现在我到了这一点,我有这个界面:
namespace myFirstCProgramIn2013
{
public interface Interface1 : IEnumerable
{
string Process { get; set; }
string ParentProcess { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
我在这个类中实现了它:
public class myArray : Interface1
{
public string Process
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public string ParentProcess
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public System.Collections.IEnumerator GetEnumerator()
{
throw new NotImplementedException();
}
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用此类使用以下代码将myResult分配给它:
List<Interface1> recordList = …Run Code Online (Sandbox Code Playgroud) 我已经声明了这个界面:
public interface Filter
{
/**
Determines whether to accept an object.
@param x the object to be filtered
@return true to accept an object, false otherwise
*/
boolean accept(Object x);
}
Run Code Online (Sandbox Code Playgroud)
所以现在我需要做的是将它与已经在类中声明和实现的另一个接口一起实现.所以我的问题是我是否可以用这种方式在同一个类中实现这两个接口.
public class DataSet implements Measurer, implements Filter{
......
}
or
public class DataSet implements Measurer, Filter{
.....
}
Run Code Online (Sandbox Code Playgroud)
谢谢
我们今天进行了Java测试,对正确的答案进行了激烈的讨论.你能用一个简单的解释帮我找到正确的答案吗?
问题:这个Java代码有什么问题?
abstract class Fluffy {
}
interface Animal {
}
class Cat extends Fluffy implements Animal {
}
class Dog extends Fluffy implements Animal {
}
Run Code Online (Sandbox Code Playgroud)
选项
您只能选择一个答案
我Cannot create an instance of the abstract class or interface在C#教程中收到错误.
它在这条线上失败了: result = new Account(nameText, addressText, balance);
这是我的班级:
public abstract class Account : IAccount
{
//---------------------------------------------------------------
// Constructor
//---------------------------------------------------------------
public Account(string inName, string inAddress, decimal inBalance)
{
name = inName;
address = inAddress;
balance = inBalance;
}
public Account(string inName, string inAddress) :
this(inName, inAddress, 0) // 'this ties this alternate constructor back to the original constructor (directly above)
{
}
public Account(string inName) : // 'this ties …Run Code Online (Sandbox Code Playgroud) data我试图在接口中实现常量,但为什么在 switch 情况下访问时会出错?
如果我只使用stringininterface而不是常量,APP_STATUS那么它就可以正常工作。
例子:
// Gives an error
interface InconsistenciesData {
type: typeof APP_STATUS.INCONSISTENCIES;
data: Inconsistency[];
}
// Works fine
interface InconsistenciesData {
type: 'INCONSISTENCIES';
data: Inconsistency[];
}
Run Code Online (Sandbox Code Playgroud)
下面是我的代码片段。
export const APP_STATUS = {
CONFIRMED: 'CONFIRMED',
INCONSISTENCIES: 'INCONSISTENCIES',
SUCCESS: 'SUCCESS',
ERROR: 'ERROR',
LOADING: 'LOADING',
OK: 'OK'
}
interface InconsistenciesLoading {
type: typeof APP_STATUS.LOADING;
}
interface InconsistenciesError {
type: typeof APP_STATUS.ERROR;
}
interface InconsistenciesSuccess {
type: typeof APP_STATUS.SUCCESS;
}
interface InconsistenciesData …Run Code Online (Sandbox Code Playgroud)