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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:07:08+00:00 2026-05-30T15:07:08+00:00

This is my class public class csWordSimilarity { public int irColumn1 = 0; public

  • 0

This is my class

public class csWordSimilarity
{
    public int irColumn1 = 0;
    public int irColumn2 = 0;
    public int irColumn3 = 0;
    public int irColumn4 = 0;
    public int irColumn5 = 0;
}

I want to make that class iterable to be used like the way below

foreach (int irVal in myVarWordSimilarity)
{

} 

myVarWordSimilarity is csWordSimilarity type. So I want to iterate all public int variables. How do I need to modify csWordSimilarity class for making it iterable like the way above.

  • 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-30T15:07:09+00:00Added an answer on May 30, 2026 at 3:07 pm

    You can implement IEnumerable and have the GetEnumerator override return an “iterator” over the variables using the yield statement

    class csWordSimilarity : IEnumerable<int>
    {
        private int _var1 = 1;
        private int _var2 = 1;
        private int _var3 = 1;
        private int _var4 = 1;
    
        public IEnumerator<int> GetEnumerator()
        {
            yield return _var1;
            yield return _var2;
            yield return _var3;
            yield return _var4;
        }
    
        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to serialize this class: public class CarDisplay { public string Name {
Say I have this class: public class Account { public int AccountID { get;
I have this class public class wordObject implements java.io.Serializable { String wordName; int occCount;
I have this class public class Subject { int ID; string Name; int Semester;
I have this class: public class MyEntity { public virtual int Id { get;
Suppose you have this class: public class A { private int number; public setNumber(int
Say I have this class Myclass that contains this method: public class MyClass {
I have this class: public class Fibonacci { public static int Calculate( int x
I have this class: public class docInfo { private int freq; private HashMap<String, Double>
I have this class: public class TestClass { public TestClass(int? foo, string bar) {

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.