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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:30:20+00:00 2026-05-11T23:30:20+00:00

I have asked this before but I didn’t get the question right so the

  • 0

I have asked this before but I didn’t get the question right so the answer was missed.

If I have a method that returns an ObservableColletion<T> how would I then use this in another generic method.

Would

method2<ObservableCollection<T>>(){} 

be the way to go.

I am trying to make a generic resultEventArgs that will pass the results of an Ado.NET Dataservices query to all subscribers. Inside that I want ot be able to pass the strongly typed EntityCollection that is returned [Ado.NET 1.5 generated]

So yes, my question is worded ObservableCollection because i didn’t want to get the whole ado.net dataservices confusion.

Cheers
Dave

  • 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-11T23:30:20+00:00Added an answer on May 11, 2026 at 11:30 pm

    It depends; do you want to specify the item type, or the collection type? If you just want to specify the item, then the T relates just to the item:

    public ObservableCollection<T> SomeMethod<T>()
    {
        var data = new ObservableCollection<T>();
        data.Add(default(T)); // or whatever
        return data;
    }
    

    Then you can use ObservableCollection<Order> orders = SomeMethod<Order>() etc. If you need to specify the collection type, you may need more generic types…

    public TList SomeMethod<TList, T>()
        where TList : class, IList<T>, new()
    {
        var data = new TList();
        data.Add(default(T)); // or whatever
        return data;
    }
    

    However, calling it is trickier. It can’t do type inference unless the list is an argument, meaning you have to specify both TList and T when calling it… not pretty.

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

Sidebar

Related Questions

This question may have been asked before, but I had trouble finding an answer,
I have asked this once before but i didnt get a very clear answer.
I have asked a similar question before, but didn't get very good results. I've
I'm aware that this question may have been asked before, but I still haven't
This question may well have been asked before but I didn't find anything whilst
This question has been asked before ( link ) but I have slightly different
No doubt elements of this question have been asked before, but I'm having trouble
I am sure that this kind of questions must have been asked before, but
I have asked this before but couldn't get it resolved, so asking again. I
I have asked this question before - but I have spent some time thinking

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.