c# loop through object

foreach (PropertyInfo prop in someObject.GetType().GetProperties())
{
    Console.WriteLine($"{prop.Name}: {prop.GetValue(someObject, null)}");
}

3.5
4
Awgiedawgie 440215 points

                                     List<string> names = new List<string>() { "Suresh Dasari", "Rohini Alavala", "Trishika Dasari" };

            foreach (string name in names)

            {

                Console.WriteLine(name);

            }

3.5 (4 Votes)
0
0
0
Awgiedawgie 440215 points

                                    static void Main()
{
    foreach (int number in SomeNumbers())
    {
        Console.Write(number.ToString() + " ");
    }
    // Output: 3 5 8
    Console.ReadKey();
}

public static System.Collections.IEnumerable SomeNumbers()
{
    yield return 3;
    yield return 5;
    yield return 8;
}

0
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
c# loop through model properties loop through jobject c# loop over class properties c# scriban iterate object array c# how to loop object c# loop all properties c# use object properties in for loop c# use object properties in loop c# c# iterate through object properties and set values c# JObject loop array loop through class object c# c# iterate over objec loop c# class property and get the property how to loop thorugh object in c# for loop through object c# go through every property at object C# C# reflection loop over properties c# loop over properties of object loop over objects c# gameobject array iteration in C# creating object in for loop c# loop JObject array c# loop property class c# how to loop through every item in an object c# c# jobject iterate using loop c# create new object in for loop for loop object c# object creation in loop c# object creation in for loop c# can you loop through part of an array c# how to iterate over object properties in c# c# loop through object and give value to property c# loop through object and add value to property for loop on object of object in c# for loop on object in c# loop on joject in c# loop throug object c# for loop objects c# how to loop through properties of a class c# looping through objects properties in c# loop thorugh object in c# for loops to iterate an object c# c# loop through properties of a class looping through properties of object C# loop through properties of a class c# c# reflection iterate over properties how to loop through class properties c# how to loop through a class of properties c# c# loop object properties loop through class properties c# c# loop through properties of object c# loop through object properties and set values c# loop through jobject csharp loop through object c# create object in for loop c# loop through all properties of a class object loop c# C# reflection loop array values how to loop through an array of objects in c# how to loop through an array in c# and store the rows in another object loop through properties in class c# iterate through all properties of an object c# how to loop over c# objct properties c# how to iterate through object properties iterate over properties object c# how to loop through objects in c# iterate through object properties c# iterate through array of objects c# iterate over jobject properties c# iterate over object properties c# C# REFLECTION LOOP THROUGH properties IN PROPERTY how to loop through every object in an array in c# unity loop through object[][] C# loop through object in c# loop through objects in object array C# loop through object to get values C# loop object array with foreach C# loop through object array C# loop through properties on an object c# loop through object properties C# loop object in csharp set object properties in a loop c# how to iterate over every property of an object in c# c# loop over object properties c# iterate array gameobject loop through all properties in c# c# for loop object itterating over an object c# How do you iterate through an object? c# c# loop trhough all object properties and writeline loop class property c# enumerate through an object c# fields enumerate through an object c# c# loop object c# loop properties of object loop objects c# C# Loop through array object C# Loop through object keys of object c# iterate over properties in an object loop mobject with object in c# c# go through every property how to cycle through an array of objects in C# csharp loop through model object c# loop through properties loop through properties names c# and get values for loop on properties of object c# looping through an object in c# c# loop through all object properties loop through string array with foreach c# c# iterate on properties c# loop through object properties inside view for loop on object array c# foreach with abjects array c# c# loop objects loop through object property c# loop object c# foreach c# object array foreach c# use object c# loop object fields get value c# loop object fields with value c# object to list in foreach c# foreach property in object c# itertae object attrubutes how to loop through properties of an object in c# C# loop in object how to loop an object property list loop over object properties c# iterate through properties c# key value c# loop through each varible and get value in a object iterate over properties of object c# c# foreach object array foreach c# list object how to loop through attributes of an object c# how to loop through properties of an object c# loop through all properties of an object c# how to loop over object items c# how to loop over object elements c# c# iterate object properties iterate properties of object c# c# iterate object how to iterate object value in c# c# loop through collection of objects traverse an object in c# foreach property in object c# foreach attribute c# c# loop through all objects in array loop through each item in single data in C# loop list object c# foreach lopp for class list in c# c sharp loop trough object c# foreach (object item in array) loop throgh an objcet array c# loop throgh objcets c# c# foreach array object loop on an object C# how to loop in objec in c# iterate over an object in c# c# iterate over objects c# iterate over object c# loop through objects c# foreach object properties loop through properties of object c# loop through each property in object c# C# loop through all properties of an object iterate over object and get all properties values c# iterate over object properties and values c# loop properties of object c# c# loop through array of objects c# loop through object properties c# foreach object in a function c# for loop object in a function iterate through fields of object c# c# object array ForEach c# + object[] iterate C# loop through array of objet c# loop through each property of object c# running for loop in property c# iterate through properties of an object traversing properties c# object iterate through properties of object c# c# iterate over object properties c# iterate through properties of object c# for loop through properties loop object properties c# c# loop through object properties and change values c# loop through object properties and get values how to loop through object and get values in c# how to loop through object in c# c# iterate through each property of object loop through object c# how to iterate through an object in c# loop through certain properties of object c# c# iterate through object properties c# loop through object
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source