如何在字符串中找到字符的位置 [英] how do I find position of character in string
问题描述
我想看通过逗号分隔的字符串和拆开字符串通过
找到逗号',然后将每个字符集放入分开
字符串 - - - 也许是一个数组,可能是表中的单独单元格 - 或 -
无论如何......任何人都可以帮我找到命令(样本)这可能吗?
这个?
实际上,我想读一个文件并使用这些逗号分隔的数据组
来加载一个数据库和这个逗号分隔的数据是需要加载的数据库表的单个数据
列...
谢谢,
Paul
对不起 - 我正在使用VB.Net和C#
" PaulThomas"写道:
我想看"通过逗号分隔的字符串和拆开字符串通过
找到逗号'然后放入每个字符集单独的字符串 - - - 可能是一个数组,也许是表格中的单独单元格 - 或 -
无论如何......任何人都可以帮我找到可能会这样做的命令(样本)吗?
实际上,我想读取一个文件并使用这些逗号分隔的数据组来加载。一个数据库和这个逗号分隔的数据是需要加载的数据库表的各个数据列...
谢谢,
Paul
使用string.split方法
Paul,
这是C#中的一个示例 - 确保您的数据没有
分隔符。
string str =" A,BC,D,E" ;; br />
char chSep ='','';
string [] arrStr = str.Split(chSep);
for(int i = 0; i< arrStr.Length; i ++)
Console.WriteLine(arrStr [i] .ToString());
Console.ReadLine();
" Chris Dunaway"写道:
使用string.split方法
I want to "look" through a comma delimited String and "take it apart" by
finding the comma''s and then put each "set of characters" into seperate
strings - - - maybe an array, maybe seperate cells in a table -or-
whatever... Can anyone help me locate the commands (samples) that might do
this?
Actually, I want to read a file and use these comma seperated groups of data
to "load" a database and this comma seperated data is the individual data
columns of the database table that needs to be loaded...
Thanks,
Paul
Sorry - I am using VB.Net and C#
"PaulThomas" wrote:
I want to "look" through a comma delimited String and "take it apart" by
finding the comma''s and then put each "set of characters" into seperate
strings - - - maybe an array, maybe seperate cells in a table -or-
whatever... Can anyone help me locate the commands (samples) that might do
this?
Actually, I want to read a file and use these comma seperated groups of data
to "load" a database and this comma seperated data is the individual data
columns of the database table that needs to be loaded...
Thanks,
Paul
Use the string.split method
Paul,
Here''s a sample in C# - make sure that your data doesn''t have the
separator.
string str="A,B C,D,E";
char chSep='','';
string[] arrStr=str.Split(chSep);
for (int i=0;i<arrStr.Length ;i++)
Console.WriteLine(arrStr[i].ToString());
Console.ReadLine();
"Chris Dunaway" wrote:
Use the string.split method
这篇关于如何在字符串中找到字符的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!