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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:06:08+00:00 2026-05-27T14:06:08+00:00

I am using silverlight 4.0 in my application. I have a method in my

  • 0

I am using silverlight 4.0 in my application. I have a method in my base class as mentioned below

class BaseClass
{
    protected CustomRequest GetCustomRequest(IEnumerable<IRequestType> types)
    {
        //Some code here...
    }
}

In my derived class when I call this method like below I get error

IEnumerable<RequestType> requestTypes = CodeToGetThis();
GetCustomRequest(requestTypes)

Note here that in calling statement the type of requestTypes is a enumerable of derived type of IRequestType.

This works well in desktop applications due to introduction of covariance in c#4.0. But it seems that for silverlight 4.0 it is not done for IEnumerable interface.

So what is the best alternative approach I should use in my silverlight application for this?

I somewhere read that it can be done using method overloading but not sure how to do this.

UPDATE:
One thing I missed in the first draft of the question is, I will have many derived types of IRequestType hence craeating overloaded method for each derived type will be a difficulty for me.

  • 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-27T14:06:09+00:00Added an answer on May 27, 2026 at 2:06 pm

    Just cast each item to the interface e.g.

    IEnumerable<IRequestType> requestTypes = CodeToGetThis().Select(x => (IRequestType)x);
    GetCustomRequest(requestTypes)
    

    You could do something with method overloading and have a method that took your derived/concrete type but you would only end up doing something like the above and calling the original method in the overload.

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

Sidebar

Related Questions

I have a Silverlight application that is using a DataGrid. Inside of that DataGrid
I have a Silverlight 3 Application and for security I'm using Active Directory. For
I am trying to develop a Silverlight 4 application using C# 4.0. I have
I have created a web application with a Silverlight project embedded in it, using
I am making a RIA application using Silverlight and web services. The method of
I am using the Business Silverlight application. I have incorporated some MVVM into this
I am using Silverlight 4 and MVVM pattern for my application. I have a
I'm using PRISM in a SilverLight 4 application. I have a problem where views
I have a windows azure Webrole application using Silverlight on top of WCF+ASP.NET. I
I have developed a silverlight 3 application using Sockets connecting to a socket server

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.