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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:07:03+00:00 2026-06-14T18:07:03+00:00

i have create a class library (DLL) with many different methods. and the return

  • 0

i have create a class library (DLL) with many different methods. and the return different types of data(string string[] double double[]). Therefore i have created one class i called CustomDataType for all the methods containing different data types so each method in the Library can return object of the custom class and this way be able to return multiple data types I have done it like this:

public  class CustomDataType
{
    public double Value;
    public string Timestamp;
    public string Description;
    public string Unit;

   // special for GetparamterInfo
    public string OpcItemUrl;
    public string Source;
    public double Gain;
    public double Offset;
    public string ParameterName;
    public int ParameterID;

    public double[] arrayOfValue;
    public string[] arrayOfTimestamp;

    //
    public string[] arrayOfParameterName;
    public string[] arrayOfUnit;
    public string[] arrayOfDescription;
    public int[]    arrayOfParameterID;
    public string[] arrayOfItemUrl;
    public string[] arrayOfSource;
    public string[] arrayOfModBusRegister;
    public string[] arrayOfGain;
    public string[] arrayOfOffset;

}

The Library contains methods like these:

public CustomDataType GetDeviceParameters(string deviceName)
    {
        ......................
        code



      getDeviceParametersObj.arrayOfParameterName;  

      return getDeviceParametersObj;

    }

    public CustomDataType GetMaxMin(string parameterName, string period, string maxMin)
    {
        .....................................code



                        getMaxMingObj.Value             =   (double)reader["MaxMinValue"];
                        getMaxMingObj.Timestamp         =   reader["MeasurementDateTime"].ToString();
                        getMaxMingObj.Unit              =   reader["Unit"].ToString();
                        getMaxMingObj.Description       =   reader["Description"].ToString(); 

        return getMaxMingObj;
    }

    public CustomDataType GetSelectedMaxMinData(string[] parameterName, string period, string mode)
    {................................code

        selectedMaxMinObj.arrayOfValue          =   MaxMinvalueList.ToArray();
        selectedMaxMinObj.arrayOfTimestamp      =   MaxMintimeStampList.ToArray();
        selectedMaxMinObj.arrayOfDescription    =   MaxMindescriptionList.ToArray();
        selectedMaxMinObj.arrayOfUnit           =   MaxMinunitList.ToArray();
        return selectedMaxMinObj;

    }

As illustrated thi different methods returns different data types,and it works fine for me but when i import the DLL and want to use the methods Visual studio shwos all the data types in the CustomDataType class as suggestion for all the methods even though the return different data.This is illusrtated in the picture below. As we can see from the picture with the suggestion of all the different return data the user can get confused and choose wrong return data for some of the methods. So my question is how can i improve this. so Visual studio suggest just the belonging return data type for each method.

enter image description here

  • 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-14T18:07:04+00:00Added an answer on June 14, 2026 at 6:07 pm

    You’re taking a fundamentally wrong approach.

    Make each method’s return type a type which includes the appropriate data. Some methods may have the same return type as each other; for other data types there may only be a single method which returns that type.

    In some cases generics may help – for example, if you have different methods which return a “minimum and maximum value”, sometimes long, sometimes int, sometimes float or whatever, then you could have a MinMax<T> type.

    This should have given you the hint:

    and the return different types of data

    Given that the methods naturally “return different types of data” why would you give them all the same return type?

    But putting everything into one data type is simply not the way forward. (It’s also extremely inefficient, but that’s a second order concern.)

    Next step: get rid of those public fields, and use properties instead. You should consider whether it would make sense for some of your types to be immutable, and where you’re currently exposing arrays, expose read-only collections instead.

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

Sidebar

Related Questions

I have created a new class library(DLL) and when I'm trying to create an
I have created a class library (dll) and I want to use this in
I have a .dll file from a Silverlight class library. How can I create
I have a signed class library that I want to create assemblies for via
I have created a class library called AddServiceLibrary in which I have a method
I have created a Class Library (Core Processing Component) using C# in Visual Studio
I have created a class library as a project. Where I have added a
I am using the apache library. I have created a class which sends a
I have create my own NSOpenGLView class, right now the data that i want
I have created a Windows Store class library. This contains some user controls and

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.