// SPDX-License-Identifier: MIT pragma solidity ^0.8.8; contract SimpleStorage { uint256 public fnumber; // People public person=People({fnumber:2,name:"xiang"}); struct People{ uint256 fnumber; string name; } People[] public perple; mapping(string=>uint256) public nameToFnumber; function store(uint256 _fnumber) public { fnumber = _fnumber; } function retrieve()public view returns(uint256){ return fnumber; } function addPerson(string memory _name,uint256 _fnumber)public{ People memory newPerson=People({fnumber:_fnumber,name:_name}); perple.push(newPerson); nameToFnumber[_name]=_fnumber; } }
标签:function,fnumber,name,People,uint256,solidity,学习,public From: https://www.cnblogs.com/s42-/p/17329208.html