April 2017
Intermediate to advanced
266 pages
7h 4m
English
In Solidity, there are two ways to create strings: using bytes and string. bytes is used to create a raw string, whereas string is used to create a UTF-8 string. The length of string is always dynamic.
Here is an example that shows string syntaxes:
contract sample{ //wherever a string literal is seen a new string is created. If the string literal is in state than it's stored in storage and if it's found inside function than its stored in memory //Here myString stores "" string. string myString = ""; //string literal bytes myRawString; function sample(string initString, bytes rawStringInit){ myString = initString; //myString2 holds a pointer to myString string myString2 = myString; //myString3 is a string in memory string ...