i have stringstr="123 456";between 3 and 4 there are spaces and tabs ,how can i decernthe spaces from tabsusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace ques{ public partial class Form1 : Form { public Form1() { InitializeComponent(); pp(); } private void pp() { int i,SumTab, SumSpace, len; string str; char[] characterArray = new char[250]; str = "123 456"; SumTab = 0; SumSpace = 0; len = str.Length; str.CopyTo(0, characterArray, 0, len); for (i = 0; i < str.Length; i++) { if (characterArray[i] == ' ') //Space SumSpace++; else if (characterArray[i] == ' ')//????? SumTab++; else ; } } }} 解决方案 这篇关于如何在字符串中查找制表符和空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-30 08:56