Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8924227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:21:12+00:00 2026-06-15T07:21:12+00:00

I am trying to develop a Windows 8 App in Visual Studio Express 2012

  • 0

I am trying to develop a Windows 8 App in Visual Studio Express 2012 for Windows 8 using C#/XAML, and I am facing some problems while doing so.

I am from a Java background and have little knowledge of C#. I am trying to translate Java Enum to C#.

I stumbled upon Jon Skeet’s Article which fits in my exact requirement. But from the comments and answers of this question, I realised that it’s a proposed idea. My bad! 🙂

However, the closest translation I found after the above article is this one:
https://stackoverflow.com/a/4778347/1127443

But even with the above implementation, VS cannot find the getCustomAttribute() method in Attribute.

How can I implement the idea of Java Enums in C# where common fields and abstract functions can be defined? Basically, I want to bring back the idea of enums as a set of allowed instances of a particular class with specific implementations.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:21:13+00:00Added an answer on June 15, 2026 at 7:21 am

    Here is what I would do to be as close to your code as possible:

    Don´t use enum, but create a static class with some constant fields:

        public static class ArithmeticOperation
        {
            public static const Func<int, int, int> Addition = (x, y) => x+y;
            public static const Func<int, int, int> Subtraction = (x, y) => x - y;
            public static const Func<int, int, int> Multiplication = (x, y) => x * y;
            public static const Func<int, int, int> Division = (x, y) => x / y;
        }
    

    You can use it just like any other method:

        static void Main(string[] args)
        {
            var result = ArithmeticOperation.Addition(1, 2);
        }
    

    Or use it in a parameter just like an enum:

        private int DoCalculation(Func<int, int, int> operation)
        {
               return operation(1, 2);
        }
    
        ...
    
         DoCalculation(ArithmeticOperations.Addition);
    

    You can pass any Func<int, int, int> as a parameter, not only ArithmeticOperation´s property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using PhoneGap to develop a Windows Phone 7 app. I'm trying to call
I an trying to develop a windows application using C# that can play streamed
We are trying to develop an app for Windows Mobile and are running into
I am trying to develop a Qt App using 4.7.3 which involves the writing
I am trying to develop a windows application using C# and SharePoint built in
I am trying to develop my first OCR app using tesseract. I'm developing under
I am trying to develop a simple sample mobile web app using MVC4, to
I am using Netbeans 7.0.1 and am trying to develop an android app. After
Let's get this out of the way... I : use Visual Studio 2012 develop
I am trying to develop Windows Phone App, I would like to know that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.