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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:12:01+00:00 2026-05-20T01:12:01+00:00

I am running into an issue that I have never encountered before with type

  • 0

I am running into an issue that I have never encountered before with type casting.

I am trying to cast an object of type TextmlBatchDeleteDocument to System.String so I implemented an explicit type conversion operator to handle accomplish this.

public override string ToString()
{
    return string.Format("{0}{1}", this.Collection, this.Name);
}

public static explicit operator string(TextmlBatchDeleteDocument doc)
{
    return doc.ToString();
}

Success, the following works.

TextmlBatchDeleteDocument doc = new TextmlBatchDeleteDocument("name", "/collection/");
string someString = (string)doc;

However I am passing an object of type List<TextmlBatchDeleteDocument> to a third party function that requires an object to implement IList and it will eventually use the objects in the list as strings. This is where I run into trouble. I get this exception whenever I try to call the third party function.

Unable to cast object of type ‘NWDA_Common.Textml.TextmlBatchDeleteDocument’ to type ‘System.String’.

If my assumptions are correct I am passing the function an object of type List<TextmlBatchDeleteDocument> but it gets cast to IList which will then treat any object in my list as the base type System.Object. I did a test to confirm this theory and got the same exception. If I cast my object of type List<TextmlBatchDeleteDocument> to System.Object first then try to do a cast to a string it will throw an exception.

TextmlBatchDeleteDocument doc = new TextmlBatchDeleteDocument("name", "/collection/");
object docAsObj = doc;
string someString = (string)docAsObj;

Is there anyone who knows how to solve this problem or am I stuck with re-factoring and finding another way?

  • 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-20T01:12:02+00:00Added an answer on May 20, 2026 at 1:12 am

    It sounds like the third party component really needs an IList where each element is a string – so that’s what you’ll need to provide it with. Conversions aren’t applied polymorphically – it’s a compile-time choice based on the compile-time type of the source expression.

    Basically, you’ll need to perform the conversion yourself for each element, and pass a list of the converted items to the third party code.

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

Sidebar

Related Questions

I'm running into an issue where I have a FileUpload control in an UpdatePanel.
I am running into an issue I had before; can't find my reference on
I am running into this issue of releasing an already released object but can't
I am running into quite an annoying issue while trying to deserialise a specific
Running into another issue that I just seem cant to find any information what
I'm running into an issue where granting EXECUTE permissions on a specific Stored Procedure
I've been running into a presentation issue with Internet Explorer. The following simple block
I am running into a randomly occuring issue, and it looks like either there
We're running into issues with how we specify font sizes. If we specify the
I'm currently running into some issues resizing images using GD. Everything works fine until

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.