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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:12:45+00:00 2026-05-21T02:12:45+00:00

Ok, lets say I have classes such as the following: public class KPIObject<T> //<–This

  • 0

Ok, lets say I have classes such as the following:

public class KPIObject<T> //<--This class where T is the following classes
{
    public List<T> Data { get; set; }
    public string Caption { get; set; }
}

public class KPICycleCountAccuracyData //<--There are 20 of these with different names and values
{
    public string Facility { get; set; }
    public string CCAdjustedCases { get; set; }
    public string TotalCases { get; set; }
    public string CCAdjustedPercent { get; set; }
}

Then I have:

public List<ReportData>> ProcessAccountReport(GetAccountReport request)
{
    var data = new List<ReportData>();
    ProcessKPI(data, request.KPICycleCountAccuracy, "KPICycleCountAccuracy"); //<-- 20 of these
    return data;
}

Here is the ProcessKPI method:

private static void ProcessKPI<T>(List<ReportData> data, ICollection<KPIObject<T>> items, string name)
{
    if (items == null || items.Count <= 0) return;
    foreach (var item in items)
    {
        if (item.Data == null || item.Data.Count <= 0) continue;
        var temp = new List<object>();
        temp.AddRange((IEnumerable<object>)item.Data);
        data.Add(new ReportData { Data = temp, Name = name, Title = item.Caption });
    }
}

All of this works and compiles correctly, I am just wondering if this is the most efficient way of doing this.

Thanks.

EDIT

I changed process KPI to this:

private static void ProcessKPI<T>(ICollection<ReportData> data, ICollection<KPIObject<T>> items, string name)
        {
            if (items == null || items.Count <= 0) return;
            foreach (var item in items.Where(item => item.Data != null && item.Data.Count > 0))
            {
                data.Add(new ReportData { Data = (IEnumerable<object>)item.Data, Name = name, Title = item.Caption });
            }
        }
  • 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-05-21T02:12:45+00:00Added an answer on May 21, 2026 at 2:12 am

    Couple of comments

    • There is no need to make data a ref parameter in ProcessKPI. A ref parameter is only meaningful for a class type in C# if you actually assign to it. Here you’re just modifying the object so ref doesn’t by you anything except awkward call syntax
    • Even though Count is signed it won’t ever return a negative value.
    • I would prefer (IEnumerable<object>)item.Data over the as IEnumerable<object> version. If the latter fails it will result in an ArgumentNullException when really it’s a casting issue.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say i have the following c# classes: abstract class a { protected abstract
Lets say we have a program which contains such classes: public interface AbstractItem {
Let's say I have some classes like this: abstract class View(val writer: XMLStreamWriter) {
Let's say i have 2 classes: class Class1 { public: std::vector<CustomClass3*> mVec; public: Class1();
Let's say we have these two classes: public class Base { public static int
Lets say I have 3 classes: class A { void do_A() { //Check object
for clarity lets say we have students and classes, its a many to many
Let's say I have two models, Classes and People. A Class might have one
Let's say I have a Base class and several Derived classes. Is there any
Let's say you have a class class C { int * i; public: C(int

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.