TextBox text spliting problem C#

Posted on 2009-04-27
Last Modified: 2012-08-13
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.
Question by:csharp_learner
    LVL 29

    Accepted Solution


    string[] params = {':'};// cretae params array
    LVL 29

    Expert Comment


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


    char[] params = {':'};// cretae params array - single quotas

    Author Comment

    Thanks for the reply.
    How can i get the "12" from
                char[] para = { ':' };

    Author Comment

    Thanks for the help
               char[] para = { ':' };
               string[] store =  textbox1.Text.Split(para);
    Worked for me.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now