splite按2个tab切割 数据是用2个tab分开的 ~用splite怎么切割啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 那就直接按空格分割呗,分完了再用一个数组存非空格的数据如:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Collections;namespace paidui{ class Program { static void Main(string[] args) { string str = "1 2 3"; string[] str1 = str.Split(' '); ArrayList str2 = new ArrayList(); for (int i = 0; i < str.Length; i++) { if (str[i]!=' ') { str2.Add(str[i]); } } foreach (char item in str2) { Console.WriteLine(item); } Console.ReadLine(); } }} 但数据不是用空格分开的啊~不然用空格我也知道 每个数据之间是2个tab分开的 Tab其实就是多个空格组成的,一般3个空格。 字符串.Split(new string[] { "\t\t" }, StringSplitOptions.RemoveEmptyEntries);或者System.Text.RegularExpressions.Regex.Split(字符串, @"\t\t"); 原先代码有错,更改下……4楼的那个方法好像没分割成功,是不是还少什么 //以两个Tab分割字符串 string str = "asdase bbsdsd casddc"; string[] str1 = str.Split(' '); ArrayList str2 = new ArrayList(); for (int i = 0; i < str1.Length; i++) { if (str1[i] !="") { str2.Add(str1[i]); } } foreach (string item in str2) { Console.WriteLine(item); } Console.ReadLine(); 那是因为Visual Studio中在字符串里面直接敲tab键默认会转成空格:string tab1 = "\t";string tab2 = " "; // 直接敲tab键string tab3 = @" "; // 先敲@再敲tabbyte[] byte1 = Encoding.UTF8.GetBytes(tab1); // 0x09byte[] byte2 = Encoding.UTF8.GetBytes(tab2); // 0x20byte[] byte3 = Encoding.UTF8.GetBytes(tab3); // 0x20,0x20,0x20,0x20 急急 C# 调用 GDI Bitblt()函数 截图 总是 黑色的 使用web client上傳檔案如何得到server回傳成功 CS模式安全性讨论。 datalist ItemDataBound绑定数据后没有值,急急,,谢谢帮忙! 关于一个控件 关于datagrid和combobox的问题 本团队找志同道合的朋友一起开发搜索程序(c# OR java)!提供我们写好的一部分搜索代码给大家研究! Linq的写法 资源本地化的问题,高手看过来 求一个思路:如何把本地数据库更新到WEB服务器的数据库中? 文件上传mysql数据库问题
如:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;namespace paidui
{
class Program
{
static void Main(string[] args)
{ string str = "1 2 3";
string[] str1 = str.Split(' ');
ArrayList str2 = new ArrayList();
for (int i = 0; i < str.Length; i++)
{
if (str[i]!=' ')
{
str2.Add(str[i]);
}
}
foreach (char item in str2)
{
Console.WriteLine(item);
}
Console.ReadLine();
}
}
}
或者
System.Text.RegularExpressions.Regex.Split(字符串, @"\t\t");
string str = "asdase bbsdsd casddc";
string[] str1 = str.Split(' ');
ArrayList str2 = new ArrayList();
for (int i = 0; i < str1.Length; i++)
{
if (str1[i] !="")
{
str2.Add(str1[i]);
}
}
foreach (string item in str2)
{
Console.WriteLine(item);
}
Console.ReadLine();
那是因为Visual Studio中在字符串里面直接敲tab键默认会转成空格:string tab1 = "\t";
string tab2 = " "; // 直接敲tab键
string tab3 = @" "; // 先敲@再敲tab
byte[] byte1 = Encoding.UTF8.GetBytes(tab1); // 0x09
byte[] byte2 = Encoding.UTF8.GetBytes(tab2); // 0x20
byte[] byte3 = Encoding.UTF8.GetBytes(tab3); // 0x20,0x20,0x20,0x20