小编nde*_*uma的帖子

在覆盖中将属性添加到属性

为什么在实现接口时允许更改属性中getter或setter的可见性和存在?

interface IFoo
{
    string Bar { get; }
}

class RealFoo : IFoo
{
    public RealFoo(string bar)
    {
        this.Bar = bar;
    }

    public string Bar { get; private set; }
}

class StubFoo : IFoo
{
    public string Bar { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

......在实现抽象类时,做同样的事情并不合法吗?

abstract class AbstractFoo : IFoo
{
    public abstract string Bar { get; }
}

class RealFoo : AbstractFoo
{
    public RealFoo(string bar)
    {
        this.Bar = bar;
    }

    // Cannot override because 'Bar' does not …
Run Code Online (Sandbox Code Playgroud)

c# properties abstract

16
推荐指数
2
解决办法
3558
查看次数

MySQL 5.7.18:外键约束和ALTER TABLE CHANGE COLUMN从NULL到NOT NULL

下面的SQL脚本工作与MySQL 17年5月16日及以上,但与一个我的MySQL 5.7.18设施(另一个中,MySQL 5.7.18在泊坞窗容器推出,是OK以及)

drop table if exists bar;
drop table if exists foo;

create table foo (foo_id int not null primary key, description varchar(32));
insert into foo values ("1", "foo-one");
insert into foo values ("2", "foo-two");

create table bar (bar_id int not null primary key, foo_id int null, description varchar(32), foreign key (foo_id) references foo(foo_id));
insert into bar values ("1", "1", "bar-one");
insert into bar values ("2", "1", "bar-two");

alter table bar change column foo_id foo_id int …
Run Code Online (Sandbox Code Playgroud)

mysql foreign-keys alter-table

6
推荐指数
1
解决办法
1571
查看次数

标签 统计

abstract ×1

alter-table ×1

c# ×1

foreign-keys ×1

mysql ×1

properties ×1