C# Enum MemberwiseClone

In this chapter you will learn:

  1. Get to know Enum.MemberwiseClone
  2. Syntax for Enum.MemberwiseClone
  3. Returns for Enum.MemberwiseClone
  4. Example - Enum.MemberwiseClone

Description

Enum MemberwiseClone creates a shallow copy of the current Object.

Syntax

Enum.MemberwiseClone has the following syntax.


protected Object MemberwiseClone()

Returns

Enum.MemberwiseClone method returns A shallow copy of the current Object.

Example


/*  w ww.j av  a 2 s  .  c  o m*/
using System;

[Flags] public enum Pets { 
      None = 0, Dog = 1, Cat = 2, Bird = 4, 
      Rodent = 8, Other = 16 };

public class Example
{
   public static void Main()
   {
      Pets value = Pets.Dog | Pets.Cat;
      value = value.MemberwiseClone();

   }
}

Next chapter...

What you will learn in the next chapter:

  1. Get to know Enum.Parse(Type, String)
  2. Syntax for Enum.Parse(Type, String)
  3. Parameter for Enum.Parse(Type, String)
  4. Returns for Enum.Parse(Type, String)
  5. Example - Enum.Parse(Type, String)