-
C# 如何用多个字符串来切分字符串并去除空格
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data;
-
- namespace Study
- {
- public static class Program3
- {
- static void Main(string[] args)
- {
- Proccess(@"13212345671,13312345672, 13412345674
- 13212345674,");
- Proccess("");
- Proccess(null);
- Console.Read();
- }
-
- public static void Proccess(string str)
- {
-
-
-
- string[] arr = (str ?? string.Empty).Split(new char[] { ',', '\t', '\n', ' ' }, StringSplitOptions.RemoveEmptyEntries);
- Console.WriteLine("本次切分后数组的长度为:{0}", arr.Length);
- int i = 1;
- foreach (string s in arr)
- {
- Console.WriteLine("{0}:{1}", (i++).ToString(), s);
- }
- }
- }
- }
-
相关阅读:
c++ 迷宫问题
linux下恢复删除的文件
c++ 分解数2
c++ 平分石头
多态
设计模式中类的6种关系
工厂方法模式
设计原则之面向接口编程
封装、继承
便利构造器、单件模式
-
原文地址:https://www.cnblogs.com/just09161018/p/4605333.html
Copyright © 2020-2023
润新知