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 8438537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:44:43+00:00 2026-06-10T07:44:43+00:00

I have this bit of code that has to iterate trough a enum and

  • 0

I have this bit of code that has to iterate trough a enum and make some calculations.

This is the enum

namespace PantaRei.Classes.Enums
{
    public class ProductTypeA1Enum
    {
        #region Reports Enum

        public enum Types
        {
            [StringValue("K01")]
            K01 = 1,
            [StringValue("K03")]
            K03 = 2,
            [StringValue("K05")]
            K05 = 3,
            [StringValue("M01")]
            M01 = 4
        }

        #endregion
    }
}

This is my function that takes a enum as parameter being Types the enum

GetData(ref secA1, ddr, ddrs, ProductTypeA1Enum.Types);

this is the code where I itereate through the enum

    public static void GetData(ref Dars secA1, Ddr ddr, Ddrs ddrs, Enum pTypes)
            {
                Array typesEnum = Enum.GetValues(pTypes.GetType());

                foreach (var types in typesEnum)
                {
                    string pType = StringEnum.GetStringValue((Enum) types);

                    secA1.OpBal = ddrs.Out.Sum(o => o.Amount);

secA1.MiCaCol +=
                ddr.Rec.Where(
                    rec =>
                    ddr.Acc.Exists(
                        acc =>
                        acc.Contract == rec.Contract && !acc.TransactionType.Equals("D9") && rec.ProductType == pType)).
                    Sum(rec => rec.Amount);
             }               
     }

And this is the error I get

PantaRei.Classes.Enums.ProductTypeA1Enum.Types' is a 'type', which is not valid in the given context    

The error comes from here

GetData(ref secA1, ddr, ddrs, **ProductTypeA1Enum.Types**);

Types is a enum, so why am I getting this error?
Any ideas?
Tks in advance
Rui Martins

  • 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-10T07:44:44+00:00Added an answer on June 10, 2026 at 7:44 am

    You should do so:

    GetData(ref secA1, ddr, ddrs, typeof(ProductTypeA1Enum.Types));
    

    and

    public static void GetData(ref Dars secA1, Ddr ddr, Ddrs ddrs, Type pTypes)
    {
        Array typesEnum = Enum.GetValues(pTypes);
    
        // ....
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bit of sample code that is throwing this warning: main.c: In
I use this bit of code to feed some data i have parsed from
I have inherited a bit of Java code that uses Hibernate. Some of the
I have inherited some code that is in need of a bit of a
I have inherited a certain bit code that has the @JsonProperty annotation on getter/setters.
I have some encryption code that has been written in Perl (also a code
I have this bit of code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data;
i have this bit of code, it limits the Li's to 15 of them
I have this bit of code, public static List<string> GetSentencesFromWords(List<string> words, string fileContents) {
So I have this bit of code for x in range(x1,x2): for y in

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.