241-solidity之bytes






solidity之bytes






contract Test{

//hello world的16进制
bytes10 public b10 = 0x68656c6c6f20776f726c64;  

bytes public bytesInfo = new bytes(b10.length);

function fixedByte2Bytes() public{
	for (uint i=0; i< b10.length; i++){
	bytesInfo[i] = b10[i];
	}
}



bytes public bytesInfo1;
function fixedByte2Bytes1() public{
	for
}






//2.bytes转换为string
string public helloworld;

function bytes2String() public{
	fixedByte2Bytes();
	helloworld = string(bytesInfo);
}


}







来写一个简单的求和

contract Test{

uint256[10] numbers = [1,2,3,4,5,6,7,8,9,10];
uint256 public sum;

function getSum() public returns(uint256){
	for(uint i=0; i

 

你可能感兴趣的:(solidity)