I need help

 

Results 1 to 13 of 13
Hello, For example you have textbox with text which will be input by user.On this ...
  1. #1
    botBuilder's Avatar
    botBuilder is offline Junior Member
    Join Date
    Mar 2013
    Location
    Tbilisi,Georgia
    Posts
    137
    Thanks
    2
    Thanked 75 Times in 25 Posts

    Default I need help

    Hello,

    For example you have textbox with text which will be input by user.On this textbox you have for example 3 words:
    "how", "are", "you".

    I want to make this 3 words in arrays like this:

    Array[0] it will be first word which is "how"
    Array[1] it will be second word which is "are"
    Array[2] it will be third word which is "you"

    So anybody can help me? in C#

    Thank you so much for advice




  2. #2
    AquaticGamer's Avatar
    AquaticGamer is offline ☆ SociableAuthority.com ☆
    Join Date
    Apr 2013
    Location
    ☆☆ BHW ☆☆
    Posts
    2,538
    Thanks
    272
    Thanked 1,004 Times in 709 Posts

    Default Re: I need help

    Use ubot XD Much easier :P

  3. #3
    botBuilder's Avatar
    botBuilder is offline Junior Member
    Join Date
    Mar 2013
    Location
    Tbilisi,Georgia
    Posts
    137
    Thanks
    2
    Thanked 75 Times in 25 Posts

    Default Re: I need help

    I don't want to make bot i want code for C# application

  4. #4
    Junkfood00 is offline dat burger
    Join Date
    Sep 2011
    Posts
    1,953
    Thanks
    373
    Thanked 1,256 Times in 689 Posts

    Default Re: I need help

    I'm not sure if C# is similar to C, you can create an array of pointers and then allocate memory using each pointer, enough memory for the string and the null byte. Or you could have a multidimensional static array but I wouldn't recommend that.

  5. #5
    CSharp is offline Newbies
    Join Date
    Jun 2013
    Location
    UK
    Posts
    42
    Thanks
    3
    Thanked 7 Times in 6 Posts

    Default Re: I need help

    why over complicate things?
    Code:
    var randomSentence = "A new string";
    string[] arrayOfWords = randomSentence.Split(' ');
    foreach(var word in arrayOfWords)
    {
        Console.WriteLine(word);
    }
    What we have done is split the original randomSentence every time there was a space character and then assigned it to an array.
    Last edited by CSharp; 07-12-2013 at 11:43 AM.

  6. #6
    botBuilder's Avatar
    botBuilder is offline Junior Member
    Join Date
    Mar 2013
    Location
    Tbilisi,Georgia
    Posts
    137
    Thanks
    2
    Thanked 75 Times in 25 Posts

    Default Re: I need help

    It's for console app i need for windows form anyone have working code? please? :|

  7. #7
    CSharp is offline Newbies
    Join Date
    Jun 2013
    Location
    UK
    Posts
    42
    Thanks
    3
    Thanked 7 Times in 6 Posts

    Default Re: I need help

    I've just given you a working code... I've commented everything this time and declared the variables explicitly, all you need to do is copy and paste it to a new console application project.

    Code:
    using System;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Enter a sentence you wish to split in to an array!");
    
                /*
                * Waits for the user to insert a sentence, once inserted 
                * the sentence is assigned to the variable named sentence
                */
                string sentence = Console.ReadLine();
    
                /* 
                * Checks if the inserted sentence is empty, if it is 
                * the method is returned and the code following
                * it is not executed.
                */
                if (string.IsNullOrWhiteSpace(sentence)) return;
    
                /* 
                * Splits the sentence in to words and assigns 
                * them to an array of strings.
                */
                string[] array = sentence.Split();
    
                /* 
                * For each word in the array, write it to console.
                */
                foreach (string word in array)
                {
                    Console.WriteLine(word);
                }
    
                Console.ReadLine();
            }
        }
    }

  8. #8
    tompots's Avatar
    tompots is online now AutoBotSolutions.com
    Join Date
    Dec 2011
    Location
    AutoBotSolutions.com
    Posts
    2,972
    Thanks
    2,143
    Thanked 2,800 Times in 1,479 Posts
    Blog Entries
    8

  9. #9
    CSharp is offline Newbies
    Join Date
    Jun 2013
    Location
    UK
    Posts
    42
    Thanks
    3
    Thanked 7 Times in 6 Posts

    Default Re: I need help

    I don't see how c++ would make it easier for him... once the string is split in to an array he can still access it through its indexer "Array[0]" etc

  10. #10
    Repulsor is offline Junior Member
    Join Date
    Jun 2013
    Location
    PHP Scripting ;)
    Posts
    196
    Thanks
    94
    Thanked 58 Times in 56 Posts

    Default Re: I need help

    Quote Originally Posted by tompots View Post
    you should learn C++ it will work better for what you are trying to do.
    That makes no sense buddy.

    This can be done using explode function in php, which is Split function in .Net. Someone else already posted the code for you.

  11. #11
    Standard Toaster is offline Regular Member
    Join Date
    Aug 2009
    Posts
    305
    Thanks
    310
    Thanked 177 Times in 68 Posts

    Default Re: I need help

    Quote Originally Posted by tompots View Post
    you should learn C++ it will work better for what you are trying to do.

    you spammin brah?

    @op, its not that hard to apply the code csharp posted in a winforms application. Are you trying to get homework help?
    Last edited by Standard Toaster; 07-12-2013 at 05:03 PM.

  12. #12
    bartosimpsonio's Avatar
    bartosimpsonio is offline U. B. Rich Soon
    Join Date
    Mar 2013
    Location
    Roaming BHW
    Posts
    4,238
    Thanks
    2,333
    Thanked 3,457 Times in 1,808 Posts

    Default Re: I need help

    Quote Originally Posted by Repulsor View Post
    That makes no sense buddy.

    This can be done using explode function in php, which is Split function in .Net. Someone else already posted the code for you.
    PHP is dangerous enough as it is , so I'd definitely stay away from explode

  13. #13
    botrockets's Avatar
    botrockets is offline Junior Member
    Join Date
    Mar 2013
    Posts
    182
    Thanks
    4
    Thanked 243 Times in 49 Posts

    Default Re: I need help

    User Csharp is right


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




BlackHatWorld on Twitter BlackHatWorld on FaceBook


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103