pragma solidity ^0.8.0;
contract test{
// string [] public T = [“1f”]; //可变
// / string [1] public T = [“1f”]; 长度固定
string [] public T;
function T_Length() view public returns (uint) {
return T.length;
}
function pushStrToT(string memory _str) public {
T.push(_str);
}
function TS() public view returns(string[] memory){
return T;
}
}
本文介绍了使用Pragmasolidity 0.8.0版本创建的智能合约,详细讲解了如何定义和操作可变与固定长度的字符串数组,并演示了获取数组长度和添加元素的方法。
389

被折叠的 条评论
为什么被折叠?



