Solidity 语言有命名空间吗?
Does Solidity language has namespace?
在Solidity语言中,我定义了ContractA
和ContractB
。
在 ContractA
内声明结构 A
,我想在 ContractB
.
内访问 A
contract ContractA {
struct A {
uint age;
string name;
}
// Some other methods and data structure
}
contract ContractB {
// how to access structure A.
}
我不想使用继承或 library
语法。
Solidity 中没有 C# 的命名空间。
如果您想在合约之间共享结构,请声明一个库。
library Structs {
struct AnyName {
uint256 id;
}
}
contract ContractA {
Structs.AnyName go;
}
在Solidity语言中,我定义了ContractA
和ContractB
。
在 ContractA
内声明结构 A
,我想在 ContractB
.
A
contract ContractA {
struct A {
uint age;
string name;
}
// Some other methods and data structure
}
contract ContractB {
// how to access structure A.
}
我不想使用继承或 library
语法。
Solidity 中没有 C# 的命名空间。
如果您想在合约之间共享结构,请声明一个库。
library Structs {
struct AnyName {
uint256 id;
}
}
contract ContractA {
Structs.AnyName go;
}