BDjobs Class :12 September 2017

//bdjobs class 
using System;


namespace Enumeration
{

    public class Customer
    {
        public string name { get; set; }
        public int gender { get; set; }

    }

    class Program
    {
        static void Main(string[] args)
        {
            Customer[] carray = new Customer[3];
            carray[0] = new Customer
            {
                name = "zaki",
                gender = 1


            };
            carray[1] = new Customer
            {
                name = "Bob",
                gender = 1
            };
            carray[1] = new Customer
            {
                name = "Nish",
                gender = 2
            };

            foreach (Customer cus in carray)
            {
                Console.WriteLine("Name ={0} && gender={1}",cus.name,getGender(cus.gender));
            }


            Console.ReadKey();
            //o for unknown
            //1 is for male
            //2 is for female
        }





        public static string getGender(int gender)
        {
            switch (gender)
            {
                case 0:
                    return "UNKNOWN";
                case 1:
                    return "MALE";
                case 2:
                    return "FEMALE";
                default:
                    return "Invalid Option";
            }
        }
    }
}
//bdjobs class 
using System;


namespace Enumeration
{

    public class Customer
    {
        public string name { get; set; }
        public Program.Gender gender { get; set; }

    }

    public class Program
    {
        static void Main(string[] args)
        {


            //int[] value=Enum.GetValues(typeof(Gender));
            //foreach (int val in value)
            //{
            //    Console.WriteLine(val);
            //}

            Customer[] carray = new Customer[3];
            carray[0] = new Customer
            {
                name = "zaki",
                gender = Gender.UNKNOWN


            };
            carray[1] = new Customer
            {
                name = "Bob",
                gender = Gender.MALE
            };
            carray[2] = new Customer
            {
                name = "Nish",
                gender = Gender.FEMALE
            };

            foreach (Customer cus in carray)
            {
                Console.WriteLine("Name ={0} && gender={1}",cus.name,getGender(cus.gender));
            }


            Console.ReadKey();
            //o for unknown
            //1 is for male
            //2 is for female
        }


        public enum Gender
        {
            UNKNOWN,
            MALE,
            FEMALE
        }



        public static string getGender(Gender gender)
        {
            switch (gender)
            {
                case Gender.UNKNOWN:
                    return "UNKNOWN";
                case Gender.MALE:
                    return "MALE";
                case Gender.FEMALE:
                    return "FEMALE";
                default:
                    return "Invalid Option";
            }
        }
    }
}

 

 

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *