Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,950 questions

51,892 answers

573 users

How to use enum in property with C#

2 Answers

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class CClass
    {
        DayOfWeek _day;
        public DayOfWeek Day
        {
            get
            {
                return _day;
            }
            set
            {
                _day = value;
            }
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            CClass CClass = new CClass();

            CClass.Day = DayOfWeek.Tuesday;

            Console.WriteLine(CClass.Day);
        }
    }
}


/*
run:
   
Tuesday
 
*/

 



answered Aug 21, 2018 by avibootz
0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    public enum ENUM
    {
        Abort, Retry, Ignore
    }
    public class CClass
    {
        ENUM enumObj;

        public CClass()
        {

        }
        public ENUM EnumProperty
        {
            get
            {
                return enumObj;
            }
            set
            {
                enumObj = value;
            }
        }
    }
    class Program
    {
        static void Main()
        {
            CClass obj = new CClass();

            obj.EnumProperty = ENUM.Retry;

            Console.WriteLine(obj.EnumProperty);
        }
    }
}


/*
run:
   
Retry
 
*/

 



answered Aug 22, 2018 by avibootz

Related questions

1 answer 196 views
196 views asked Aug 7, 2018 by avibootz
1 answer 151 views
151 views asked Aug 22, 2018 by avibootz
1 answer 148 views
2 answers 169 views
169 views asked Jan 18, 2017 by avibootz
1 answer 177 views
7 answers 353 views
353 views asked Mar 19, 2023 by avibootz
1 answer 316 views
...