gpt4 book ai didi

C# : I have problem with createing implement interface object

转载 作者:行者123 更新时间:2023-12-04 16:59:33 24 4
gpt4 key购买 nike

class MySql : IDatabase
{
IDatabaseConnection con;
public MySql() {
this.con = new MySqlConnection();
this.con.connect();
}
}

class ScheduleServices
{
IDatabase mysql;
public ScheduleServices() {
**this.mysql = new MySql();**
}
}

类 ScheduleServices 尝试构建 MySql 对象,该类实现 IDatabase 接口(interface)。错误说

MySql is a 'namespace' but is used like a 'type'



如何将 MySql 构建为对象?

最佳答案

您认为对 MySQL 类的引用是指其他内容(ScheduleServices 的 using 依赖项之一)。如果 ScheduleServices 文件中有歧义,请使用完全限定名称来引用 MySQL 类,重命名 MySQL 类以避免冲突,或使用别名 using 语句。

关于C# : I have problem with createing implement interface object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4246822/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com