Hi guys.. I don't know how to do this, the result would be like this,

you input then the repeated numbers would appear once only..

like this Screenshot

Attachments sample_lng.jpg 12.7 KB

do you need to worry with the order of the numbers? if not you could easily work with the numbers as strings. split them into an array by the space, create a destination and list and loop through them, if the dest list doesn't already contain the value, then add it.

pretty simple.

this will not double output the number if I use string?

can you give me an example? sorry im a newbie in C#

@ddanbe

sorry i dont have a code that have made my self..

I tried to make one.. but it seems.. it is all wrong.. sorry...

Edited 7 Years Ago by wil0022: n/a

please keep in mind that we are not apt to giving out free code. but this is so simple it only took me 3 minutes to write it.

private string removedDup(string s)
        {

            string[] allnumbers =s.Split(new char[] { ' ' });

            List<string> cutnumbers = new List<string>();

            foreach (string num in allnumbers)
            {
                if (!cutnumbers.Contains(num))
                {
                    cutnumbers.Add(num);
                }
            }

            string final = "";

            foreach(string ss in cutnumbers)
            {
                final += ss + " ";
            }

            return final.Trim();


        }

just a simple method, pass to it a string with numbers separated by spaces, and it returns a string with numbers separated by spaces. That simple.

please keep in mind that we are not apt to giving out free code. but this is so simple it only took me 3 minutes to write it.

private string removedDup(string s)
        {

            string[] allnumbers =s.Split(new char[] { ' ' });

            List<string> cutnumbers = new List<string>();

            foreach (string num in allnumbers)
            {
                if (!cutnumbers.Contains(num))
                {
                    cutnumbers.Add(num);
                }
            }

            string final = "";

            foreach(string ss in cutnumbers)
            {
                final += ss + " ";
            }

            return final.Trim();


        }

just a simple method, pass to it a string with numbers separated by spaces, and it returns a string with numbers separated by spaces. That simple.

thanks... I'll try this one, but could I make a my own without creating "private string removedDup(string s)" like this? thanks a lot..

thanks... I'll try this one, but could I make a my own without creating "private string removedDup(string s)" like this? thanks a lot..

if you didn't want it to be a method, you could easily just remove that part, start with a sting called s and the final product here is declared as final.

sorry i dont have a code that have made my self..

I tried to make one.. but it seems.. it is all wrong.. sorry...

That is just the code we like to see!
I have already posted code here of wich I am not proud, but the guys and girls here explained it and I learned from it!
Do the same!
Unless you are sitting there, with an attitude of: I have to take up a C# course. I'm not interested. The teacher sucks. Just waiting until DANIWEB gives an answer... Diamonddrake whom I appreciate very much, is a very kind person.

That is just the code we like to see!
I have already posted code here of wich I am not proud, but the guys and girls here explained it and I learned from it!
Do the same!
Unless you are sitting there, with an attitude of: I have to take up a C# course. I'm not interested. The teacher sucks. Just waiting until DANIWEB gives an answer... Diamonddrake whom I appreciate very much, is a very kind person.

that's why im thankful that Diamonddrake visited my thread.. my tomorrow morning i could show you some code... it's so late now guys.. thanks for helping me out.. maybe tomorrow i could show you the code.. even it is all wrong... thanks... gudnyt :D

This article has been dead for over six months. Start a new discussion instead.