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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:42:25+00:00 2026-05-11T19:42:25+00:00

I’m using an API that has a method that requires this type of argument:

  • 0

I’m using an API that has a method that requires this type of argument:

System.Collections.ObjectModel.Collection<GenericTickType> genericTickList

How do I instantiate an object for that argument? Here’s what I’ve tried but it keeps saying that the method call has some invalid arguments.

List<TickType> ticks_to_get = new List<TickType> { TickType.Price };

I’ve tried instantiating a Collection directly instead of a List and that doesn’t seem to work.

  • 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-11T19:42:25+00:00Added an answer on May 11, 2026 at 7:42 pm

    “I’ve tried instantiating a Collection directly instead of a List and that doesn’t seem to work.”

    What error do you get? You can definitely create an instance of Collection<T> directly, it is not an abstract class and it has several public constructors, including one that’s parameter-less. You can do this, for example:

    var values = new System.Collections.ObjectModel.Collection<int> { 1,2,3,4 };
    

    I noticed your sample code has a GenericTickType and a TickType. Is this a mistake or do you actually have two classes? You said it’s an enum (which one?), so one cannot possibly derive from the other. If they are two enum types, Collection<GenericTickType> and Collection<TickType> are two different classes and one is not assignable to the other.

    Now, if TickType is castable to GenericTickType (and they probably are if they are both enums, and assuming they share the same numeric values), you still cannot cast Collection<TickType> to Collection<GenericTickType>. There’s no contra/co-variance in C# for most classes yet (coming in C# 4). But you could cast each TickType by doing something like this:

    List<GenericTickType> list = new List<GenericTickType> { (GenericTickType)TickType.Price };
    list.Add((GenericTickType)TickType.Price); // add more...
    Collection<GenericTickType>genericTicks = new Collection<GenericTickType>(list);
    

    If you already have a List<TickType> and have access to C# 3.0 and LINQ, you can do this:

    List<TickType> ticks = new List<TickType> { TickType.Price };
    list.Add(TickType.Price); // add more...
    List<GenericTickType> castedList = ticks.Cast<GenericTickType>().ToList();
    Collection<GenericTickType>genericTicks = new Collection<GenericTickType>(castedList);
    

    This uses the LINQ Cast<T>() and ToList<T>() extension methods to cast each TickType in the original list to GenericTickType and creating a new List<GenericTickType> which is used to instantiate the Collecion<GenericTickType>. (I avoided using var so you could see the types in each step).

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

Sidebar

Ask A Question

Stats

  • Questions 168k
  • Answers 168k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer A couple of alterations needed: db.DeleteObject(detail); and db.SaveChanges(); Kindness, Dan… May 12, 2026 at 1:48 pm
  • Editorial Team
    Editorial Team added an answer Google Wave hasn't been released yet. May 12, 2026 at 1:48 pm
  • Editorial Team
    Editorial Team added an answer Yes, you do need to keep track if you're using… May 12, 2026 at 1:48 pm

Related Questions

In order to apply a triggered animation to all ToolTip s in my app,
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.