字符转换

2026-07-15 15:10:38 来源:  点击数: 

字符转换

要把 Char 转成数字类型,需要显式转换:

  • Use .code to get the numeric Unicode value of a character:

    val letter = 'A'
    println(letter.code) // 65
    
  • If a character represents a decimal digit, use digitToInt():

    val digit = '7'
    println(digit.digitToInt()) // 7

     

     

     

    If the character may not be a valid digit, use digitToIntOrNull().


上一篇:按位操作
下一篇:返回列表
关键字:

河池新闻

图说城市 图说天下

阅读排行 阅读排行


爱河池