• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 580
  • Last Modified:

TextBox text spliting problem C#

Hi,
I'm trying to Split a Text Box text containing something like
12: Australia(country)
I just want the "12" element, I tried "string[] loca = textbox1.Text.Split(":");" but the compilation error of
"The best overloaded method match for 'string.Split(params char[])' has some invalid arguments" and "Argument '1': cannot convert from 'string' to 'char[]'" kept blocking.

Thanks for the help in advance.
0
csharp_learner
Asked:
csharp_learner
  • 2
  • 2
1 Solution
 
anarki_jimbelCommented:
try:

string[] params = {':'};// cretae params array
textbox1.Text.Split(params);
0
 
anarki_jimbelCommented:
Sorry,

it should be
string[] params = {":"};// cretae params array - quotas


or


char[] params = {':'};// cretae params array - single quotas
0
 
csharp_learnerAuthor Commented:
Thanks for the reply.
How can i get the "12" from
            char[] para = { ':' };
            textbox1.Text.Split(para);
0
 
csharp_learnerAuthor Commented:
Thanks for the help
           char[] para = { ':' };
           string[] store =  textbox1.Text.Split(para);
Worked for me.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now