Click to See Complete Forum and Search --> : Set


IamOnline
April 29th, 2009, 07:56 PM
I have to learn the basics of programming now, I run into a little problem of set
I'd like to get the union of 2 numeric sets. Is there a built-in function for me to do this ?

Thanks :)

ozzy66
April 30th, 2009, 04:17 AM
:confused: set, union, what :confused: specify the problem exactly. Which context are you talking about numeric sets? :confused:

JonnyPoet
May 1st, 2009, 03:52 AM
I have to learn the basics of programming now, I run into a little problem of set
I'd like to get the union of 2 numeric sets. Is there a built-in function for me to do this ?

Thanks :)There is nothing like Union in C# This was an old C++ feature I think mostly used in structures as much as I remember. Forget this in modern OOP using C#

When starting new in a language at first you need to be able to think in new patterns. Even this is an imperative language too we still ahve a totally other pattern then C++ had. C# is an well done mixture of advatages of a big bottle of VB, mixed with a small dash of C++ and a splash of java :D IMHO getting an easy to learn full featured langauge.

But you need
a) learning the features like classes, Generics, delegates, interfaces,
and tools like Indexers, boxing, unboxing
b) learning how to use restrictions in generics and other specialities
c) learning the design patterns and how they are done in this language
d) doing lots of examples

BUT FORGET THE OLD PATTERNS and dont try to 'transform' them into the new language. Thats bullsh.. ;)

Peter_B
May 1st, 2009, 10:57 AM
There is nothing like Union in C# This was an old C++ feature I think mostly used in structures as much as I remember. Forget this in modern OOP using C#

As he is talking about sets he means 'union' to be the union of two sets, i.e. the set which contains all members of the original sets.

To IamOnline: For the set, use the HashSet class (http://msdn.microsoft.com/en-us/library/bb359438.aspx).
There isn't a built-in union method, but all you have to do is make an empty set, then add all the items in set 1 and all the items in set 2.

JonnyPoet
May 1st, 2009, 12:14 PM
... There isn't a built-in union method, but all you have to do is make an empty set, then add all the items in set 1 and all the items in set 2.Hmm ...If he is talking about HashSet : There is UnionWith() method and he maybe wants to use this Here is an example
http://msdn.microsoft.com/en-us/library/bb342097.aspx

Peter_B
May 1st, 2009, 12:21 PM
Ah - I didn't see the UnionWith() method. I don't use C# myself - I just googled it. :)

But yes, this looks like the best way to do it.

JonnyPoet
May 1st, 2009, 01:29 PM
Ah - I didn't see the UnionWith() method. I don't use C# myself - I just googled it. :)

But yes, this looks like the best way to do it.But it was the right hint into the direction, because as I had done years in old C ( before C++ ) and Union was 'that' theme there in the first structures we did so I didn't look that he wrotes about 'set' :wave:
So: Well done :thumb:

Tealc
May 3rd, 2009, 03:00 PM
Guess I don't know what he means and don't have any desire to try a figure it out. I'm tired of seeing threads with tittles like "help" "ASSISTANCE REQUIRED FAST" "Set" and then you open them and the entire thead says "hi. How do I write a program? Thanks "

Then you google there question and 500 results show up on the first page. If ppl don't know how to use a computer, how to use google or how to post a simple thread, I don't know how they think they are going to program anything. If you cause use a computer, you can't program a computer.

They can't even take 3 seconds to read the rules of posting or use code tags. Why should ppl here take more then 3 seconds trying to help them?

JonnyPoet
May 3rd, 2009, 06:10 PM
...Why should ppl here take more then 3 seconds trying to help them?Sometimes I'm going with you ;) because its frustrating if you do a half an hour work for someone e.g creating and testing an rege expression and the answer to the post is... nothing The poster simple changes the thread title to resolved and thats all. Not even - thx or something to show some manners :rolleyes:

On the other side you can get a lot of fun when you can see other people asking and understanding and half a year later you see them answering others post themselves. Any by this, sometimes you get really good friends here and thats only one of the points why I like CG. :wave: Even it has sometimes frustrating moments too, but thats life !