查看String - String()的源代码
←
String - String()
跳转至:
导航
、
搜索
因为以下原因,你没有权限编辑本页:
你刚才请求的操作只对属于该用户组的用户开放:
用户
您可以查看并复制此页面的源代码:
:[[String - object|String]] {| border="0" cellpadding="20" width="100%" |- |width="100%" valign="top" align="left"| <font color="olivedrab" size="+3">'''String()'''</font> <font color="orange" size="+1">'''描述'''</font> Constructs an instance of the String class. There are multiple versions that construct Strings from different data types (i.e. format them as sequences of characters), including: - a constant string of characters, in double quotes (i.e. a char array) - a single constant character, in single quotes - another instance of the String object - a constant integer or long integer - a constant integer or long integer, using a specified base - an integer or long integer variable - an integer or long integer variable, using a specified base - a float or double, using a specified decimal palces Constructing a String from a number results in a string that contains the ASCII representation of that number. The default is base ten, so <pre style="color:dimgray"> String thisString = String(13); </pre> gives you the String "13". You can use other bases, however. For example, <pre style="color:dimgray"> String thisString = String(13, HEX); </pre> gives you the String "D", which is the hexadecimal representation of the decimal value 13. Or if you prefer binary, <pre style="color:dimgray"> String thisString = String(13, BIN); </pre> gives you the String "1101", which is the binary representation of 13. <font color="orange" size="+1">'''语法'''</font> String(val) String(val, base) String(val, decimalPlaces) <font color="orange" size="+1">'''参数'''</font> val: a variable to format as a String - string, char, byte, int, long, unsigned int, unsigned long, float, double base (optional) - the base in which to format an integral value decimalPlaces (only if val is float or double) - the desired decimal places <font color="orange" size="+1">'''返回值'''</font> an instance of the String class <font color="orange" size="+1">'''示例'''</font> All of the following are valid declarations for Strings. <pre style="color:dimgray"> String stringOne = "Hello String"; // using a constant String String stringOne = String('a'); // converting a constant char into a String String stringTwo = String("This is a string"); // converting a constant string into a String object String stringOne = String(stringTwo + " with more"); // concatenating two strings String stringOne = String(13); // using a constant integer String stringOne = String(analogRead(0), DEC); // using an int and a base String stringOne = String(45, HEX); // using an int and a base (hexadecimal) String stringOne = String(255, BIN); // using an int and a base (binary) String stringOne = String(millis(), DEC); // using a long and a base String stringOne = String(5.698, 3); // using a float and the decimal places </pre> |} ---- [[String - object|返回String]] [[Arduino语法参考 | 返回Arduino语法参考列表]] 更多建议和问题欢迎反馈至 [http://www.yfrobot.com YFRobot论坛]
返回
String - String()
。
导航菜单
个人工具
登录
名字空间
页面
讨论
不转换
变种
不转换
简体
繁體
大陆简体
香港繁體
澳門繁體
大马简体
新加坡简体
台灣正體
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
YF-论坛提问
YFRobot-直营店
YFRobot-企业店
Arduino
Arduino之入门篇
Arduino入门教程
Arduino语法参考
Arduino库
Arduino核心代码
编程平台
Mixly库
Mind+库
MakeCode扩展
传感器系列
积木式传感器系列
黑板传感器系列
蓝板传感器系列
Micro:Bit
Micro:Bit 通用基础教程
Valon智能车
Valon-I
帮助
帮助
wiki语法参考
工具箱
链入页面
相关更改
特殊页面
页面信息