loop over object properties c#
foreach (PropertyInfo prop in someObject.GetType().GetProperties())
{
Console.WriteLine($"{prop.Name}: {prop.GetValue(someObject, null)}");
}
loop over object properties c#
foreach (PropertyInfo prop in someObject.GetType().GetProperties())
{
Console.WriteLine($"{prop.Name}: {prop.GetValue(someObject, null)}");
}
C# loop through array of objet
List<string> names = new List<string>() { "Suresh Dasari", "Rohini Alavala", "Trishika Dasari" };
foreach (string name in names)
{
Console.WriteLine(name);
}
c# loop through object
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;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us