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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:31:32+00:00 2026-06-14T17:31:32+00:00

I have to realize a serializazion/deserialization class and i’m using System.Xml.Serialization . I have

  • 0

I have to realize a serializazion/deserialization class and i’m using System.Xml.Serialization. I have some IList<Decimal> type properties and wanted to serialize in IList<string> decoding all decimal value belonging to the list with a specific culture info. For example 10 is 10,00 with Italian culture info but 10.00 with English culture info.
I tried to do it using this:

public IList<string> method()
    {
        for (int i = 0; i < 1000; i++)
        {
            yield return i.ToString();
        }
    }   

But i get at compile time Error 33

The body of 'Class1.method()' cannot be an iterator block because 'System.Collections.Generic.IList<string>' is not an iterator interface type

If i use as property type IEnumerable<string> it works succesfully but obviusly i can’t change the type of data i want to serialize .

Any help is appreciated.

  • 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-06-14T17:31:34+00:00Added an answer on June 14, 2026 at 5:31 pm

    yield only works with IEnumerable<T>, IEnumerable, IEnumerator<T> and IEnumerator as return type.
    In your case, you need to use a normal method instead:

    public IList<string> method()
    {
        var result = new List<string>();
        for (int i = 0; i < 1000; i++)
        {
            result.Add(i.ToString());
        }
        return result;
    }
    

    Think about it. Your code would allow you to write the following code:

    method().Add("foo");
    

    That doesn’t make too much sense, does it?

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

Sidebar

Related Questions

Developing a project of mine I realize I have a need for some level
I have to realize a system with different kind of users and I think
I've been using XML serialization for a while, and today I realized something really
I realize that there have already been several threads on this type of question,
I realize that similar questions have been asked before. My list is displayed using
Lately I have come to realize that I should know some of Java for
We have a number of data objects that realize INotifyPropertyChanged to allow for WPF
So I realize that the docs have the list of node types for the
I realize this is a basic question but I have searched online, been to
I realize that iOS has the ability to have keyboard shortcuts (e.g.: Command-C for

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.