CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: Set

  1. #1
    Join Date
    Apr 2009
    Posts
    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

  2. #2
    Join Date
    Dec 2002
    Location
    at home and at office :D
    Posts
    126

    Re: Set

    set, union, what specify the problem exactly. Which context are you talking about numeric sets?
    Better ask and make a rhyme
    than search dead threads for a long time.

  3. #3
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Set

    Quote Originally Posted by IamOnline View Post
    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

  4. #4
    Join Date
    Jan 2009
    Posts
    596

    Re: Set

    Quote Originally Posted by JonnyPoet View Post
    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.

  5. #5
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Set

    Quote Originally Posted by Peter_B View Post
    ... 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

  6. #6
    Join Date
    Jan 2009
    Posts
    596

    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.

  7. #7
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Set

    Quote Originally Posted by Peter_B View Post
    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

  8. #8
    Join Date
    Apr 2009
    Posts
    19

    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?

  9. #9
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Set

    Quote Originally Posted by Tealc View Post
    ...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

    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. Even it has sometimes frustrating moments too, but thats life !
    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
  •  





Click Here to Expand Forum to Full Width

Featured