zoukankan      html  css  js  c++  java
  • c# 第五课 string

    Strings: immutable(不可变)的unicode字符序列。

    string s1 = "One Two Three Four";

    string sx = (string)s1.Clone(); //s1复制到sx

    Console.WriteLine(Object.ReferenceEquals(s1, sx));  //True:相同引用

    sx += “ Five”;//sx修改

    Console.WriteLine(Object.ReferenceEquals(s1, sx)); // False:不同的引用

    Console.WriteLine(sx); // 显示"One Two Three Four Five"
     
     
    ToString() method
    Another common way to create a string is to call the ToString() method on an object and assign the result to astring variable.

    int myInteger = 5;

    string integerString = myInteger.ToString();

    split函数  用来过滤字符串中的字符

    class Program
        {
            static void Main(string[] args)
            {
                string words = "one,twot,hree,four,five";
                string[] splitedString = words.Split(',');
                foreach (string s in splitedString)
                {
                    Console.Write(s);
                }
            }
    

     输出结果为

    其中的“,”被过滤掉了。
  • 相关阅读:
    Python与数据库
    初识matplotlib
    Jquery--实现轮播图
    Juery入门2
    CSS布局方式
    Jquery入门一
    html-DOM了解
    jquery --入门
    JS练习
    kettle 报错汇总
  • 原文地址:https://www.cnblogs.com/GSONG/p/4440001.html
Copyright © 2011-2022 走看看