0
点赞
收藏
分享

微信扫一扫

旅游项目day03

Resin_Wu 2024-01-19 阅读 27

文章目录

1. 介绍

1.1 基本介绍

  类结构

  String官方参考文档:String类
在这里插入图片描述

1.2 深层细节

2. 构造和属性

2.1 String 构造

  相关构造方法
在这里插入图片描述

class Test {
    static void Main(string[] args) {
        string s = new string("hello, world.");
    }
}

2.2 String 属性

class Test {
    static void Main() {
        string str = "hello, world";

        Console.WriteLine(str.Length);
        Console.WriteLine(str[1]);
    }
}
/*
12
e
*/

3. 方法

3.1 字符串判定

  总结

  代码

class Test {
    static void Main() {
        string[] s = new string[] {
            null, 
            String.Empty, 
            "", 
            "  \t  ", 
            "hello" 
        };


        for(int i = 0; i < s.Length; i ++) {
            Console.Write(String.IsNullOrEmpty(s[i]) + " "); // True True True False False
        }
        Console.WriteLine();

        for(int i = 0; i < s.Length; i++) { 
            Console.Write(String.IsNullOrWhiteSpace(s[i]) + " "); // True True True True False
        }
    }
}
举报

相关推荐

day03

Day03

Day03(

Linux Day03

day03 事件高级

Java基础day03

web开发day03

0 条评论