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

  • Home
  • SEARCH
  • 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 6021149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:40:16+00:00 2026-05-23T03:40:16+00:00

I have a problem about designing my application. I have a webservice with methods.

  • 0

I have a problem about designing my application. I have a webservice with methods. Methods will return a encrypted binary data. Data after decrypting is a list of objects. Object can be Object1, or Object2, or Object3 which depend on called method.

I want to write only one function which return a List of object I want depend on called method. Example:

public static List<TKey> Generate(DataType type)
        {
            List<TKey> l = new List<TKey>();
            switch (type)
            {
                case DataType.String:
                    byte[] data = Decrypt(MyWebService.GetData1());
                    l = (List<TKey>)data;

                case DataType.Int:
                    byte[] data = Decrypt(MyWebService.GetData1());
                    l = (List<TKey>)data;
            }
            return l;
        }

Note: this function has error when building. I give this function so that you can understand my purpose.

My Purpose is here:

List<string> myString = Generate(DataType.String);
List<int> myInt = Generate(DataType.Int);

Thanks.

  • 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-23T03:40:16+00:00Added an answer on May 23, 2026 at 3:40 am

    You are most likely looking for a generic method:

    public static List<T> Generate<T>()
    {
       byte[] data = Decrypt(MyWebService.GetData1());
       List<T> l = Deserialize<T>(data);   
       return l;
    }
    

    You also will need a type specific deserialization method (Deserialize in the example), which would do the actual work of converting an arbitrary byte array into a list of a specific type – since it is entirely up to you how that mapping should work (the framework can’t know really) you will have to implement it yourself.

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

Sidebar

Related Questions

I have hit upon this problem about whether to use bignums in my language
The problem is not about randomness itself (we have rand), but in cryptographically secure
I have a tricky problem that I've been messing about with for a few
I've been thinking about this problem for a while and have yet to come
I have a fairly simple sync problem. I have a table with about 10
I have problem with return statment >.< I want to store all magazine names
I am designing reports using freemarker, I have a problem where I need the
I am very new to C and I have some problems learning about pointers.
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with starting processes in impersonated context in ASP.NET 2.0. I am

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.