Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. How do I clone events?

How do I clone events?

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Daniel Persson
    wrote on last edited by
    #1

    Hi! Recently I have bumped into a problem which I never have had before. I've got an object which have a couple of onChange events, I am doing some clones of this object and I really need to "copy" the events that the original object had into the new ones. Anyone who can help me Thanks // Daniel

    S 1 Reply Last reply
    0
    • D Daniel Persson

      Hi! Recently I have bumped into a problem which I never have had before. I've got an object which have a couple of onChange events, I am doing some clones of this object and I really need to "copy" the events that the original object had into the new ones. Anyone who can help me Thanks // Daniel

      S Offline
      S Offline
      Super Lloyd
      wrote on last edited by
      #2

      1. make a subclass and call base.MemberwiseClone() 2. serialize then deserialize (caution, it would be a deep copy) 3. Use reflection to call the protected MemberwiseClone() method (requires full trust)

      D 1 Reply Last reply
      0
      • S Super Lloyd

        1. make a subclass and call base.MemberwiseClone() 2. serialize then deserialize (caution, it would be a deep copy) 3. Use reflection to call the protected MemberwiseClone() method (requires full trust)

        D Offline
        D Offline
        Daniel Persson
        wrote on last edited by
        #3

        Thanks for your answer, I implemented it using MemberwiseClone() easiest right now and I think it will do. But if for some reason any of you have got a nice way to show ... please feel free to do so.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups