zoukankan      html  css  js  c++  java
  • ethereum(以太坊)(基础)--容易忽略的坑(三)

    pragma solidity ^0.4.10;
    
    contract Byte{
        
        bytes [] public T=new bytes[](3);
        
        function setLeng(uint len) public{
            T.length=len;
            T.push('0x11');
        }
        
        //bytes [5] public T1=new bytes[](5);
        //Type bytes memory[] memory is not implicitly convertible to 
        //expected type bytes storage ref[5] storage ref
        
        //bytes [5] public T1 = [1,2,3,4,5];
        //Type uint8[5] memory is not implicitly convertible to expected 
        //type bytes storage ref[5] storage ref
        
        uint [5] public T1=[1,2,3,4,5];
        
        //bytes [2] public T2 = [0x11,0x12];
        //uint [] storage T2= new uint[](5);Expected identifier, got 'Storage'
        
        
        uint []  public T2= new uint[](5);
        function setLeng1(uint len) public{
            //T1.length=len;//Expression has to be an lvalue
            //uint [5] memory T0=[1,2,3,4,5];Type uint8[5] memory is not implicitly convertible to expected type uint256[5] memory
            uint [5] memory T1=[uint(1),2,3,4,5];
            for (uint i;i<T1.length;i++){
                T2[i] = T1[i];
            }
        }
        
        
        function getByte() view public returns(bytes){
            //return T;
            //return bytes(T2);
        }
        
        bytes3 public b=0x123344;
        byte[3] public b1;
        bytes public b2 = new bytes(3);
        string public s1="liny";
        
        function f0() public{
            for(uint i;i<b.length;i++){
                b2.push(b[i]);
            }
        }
        function f1() returns(string){
            return string(b2);//"string: u0000u0000u0000u00123D"
        }
        function f2() returns(bytes){
            return bytes(s1);//bytes: 0x6c696e79
        }
    }
  • 相关阅读:
    表单的重复提交问题
    js日期操作
    spring data jpa
    Excel Xll开发资料
    Excel DNA学习笔记一
    error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏的解决方案
    点进去勿喷
    hdu1305(字典树)
    2018 Multi-University Training Contest 3
    hihocoder 1014(字典树)
  • 原文地址:https://www.cnblogs.com/eilinge/p/10081501.html
Copyright © 2011-2022 走看看