-
April 29th, 2009, 07:56 PM
#1
Set
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
-
April 30th, 2009, 04:17 AM
#2
-
May 1st, 2009, 03:52 AM
#3
Re: Set
Originally Posted by IamOnline
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 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..
Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
-
May 1st, 2009, 10:57 AM
#4
Re: Set
Originally Posted by JonnyPoet
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.
-
May 1st, 2009, 12:14 PM
#5
Re: Set
Originally Posted by Peter_B
... 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
Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
-
May 1st, 2009, 12:21 PM
#6
Re: Set
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.
-
May 1st, 2009, 01:29 PM
#7
Re: Set
Originally Posted by Peter_B
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'
So: Well done
Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
-
May 3rd, 2009, 03:00 PM
#8
Re: Set
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?
-
May 3rd, 2009, 06:10 PM
#9
Re: Set
Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|