foreach(var prop in myVar.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
{
Console.WriteLine("Name: {0}, Value: {1}",prop.Name, prop.GetValue(myVar,null));
}
More Related Contents:
- How to access property of anonymous type in C#?
- Define if statement for property in C# [closed]
- Get property value from string using reflection
- Can anonymous class implement interface?
- Should I use public properties and private fields or public fields for data?
- Returning anonymous type in C#
- How to modify or delete items from an enumerable collection while iterating through it in C#
- Setting/getting the class properties by string name [duplicate]
- C# Iterating through an enum? (Indexing a System.Array)
- How to check whether an object has certain method/property?
- How to set value for property of an anonymous object?
- Any reason to use auto-implemented properties over manual implemented properties?
- How do I automatically display all properties of a class and their values in a string? [duplicate]
- Are get and set functions popular with C++ programmers?
- .NET DefaultValue attribute
- Why we need Properties in C#
- Overriding fields or properties in subclasses
- Extracting Windows File Properties (Custom Properties) C#
- Debugging automatic properties
- Anonymous type result from sql query execution entity framework
- What does the => operator mean in a property or method?
- What is difference between Init-Only and ReadOnly in C# 9?
- Easy creation of properties that support indexing in C#
- Write-Only properties, what’s the point? [duplicate]
- How to get current property name via reflection?
- Method vs Property in C# – what’s the difference [duplicate]
- Why are public fields faster than properties?
- Adding custom attributes to an element in XAML?
- How do static properties work in an asp.net environment?
- How can I get the value of a string property via Reflection?