Answers for "how to print all variables of an object c#"

C#
0

c# print all property values of object

public static string PropertyList(this object obj)
{
  var props = obj.GetType().GetProperties();
  var sb = new StringBuilder();
  foreach (var p in props)
  {
    sb.AppendLine(p.Name + ": " + p.GetValue(obj, null));
  }
  return sb.ToString();
}
Posted by: Guest on April-13-2021
-1

how to print a variable in c#

using System;

namespace Simple
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("This is C#");
        }
    }
}
Posted by: Guest on March-24-2021

Code answers related to "how to print all variables of an object c#"

C# Answers by Framework

Browse Popular Code Answers by Language