Thursday, January 30, 2014

How to pass Enum as Method Parameter in C#.net

  private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            CheckForEnum(MyEnum.Male );
        }
        public void CheckForEnum(MyEnum en) {
          int id =  (int)Enum.Parse(typeof(MyEnum), Convert.ToString(en), true);
            MessageBox.Show((id).ToString());
        }

 public enum MyEnum :int{
        Male = 1 ,   Female=2
    }

No comments:

Post a Comment