美文网首页
三、Solidity中的string运用

三、Solidity中的string运用

作者: 书写只为分享 | 来源:发表于2021-03-23 08:49 被阅读0次
pragma solidity ^0.5.1;

contract HelloWord{
   string  public name= "zhuxing";
    
    
    function getName() view public returns( string memory){
        return name;
    }
    
    function setName(string memory _name ) public {
        name=_name;
    }
    
    function getLength() public view returns(uint){
        return bytes(name).length;
    }
    
    function changName() public{
        bytes(name)[0]='Z';
    }
    
    function getBytes() public view returns(bytes memory){
        return bytes(name);
    }
}

相关文章

网友评论

      本文标题:三、Solidity中的string运用

      本文链接:https://www.haomeiwen.com/subject/kcnthltx.html