C#: Printing all properties of an object [duplicate]

You can use the TypeDescriptor class to do this: foreach(PropertyDescriptor descriptor in TypeDescriptor.GetProperties(obj)) { string name = descriptor.Name; object value = descriptor.GetValue(obj); Console.WriteLine(“{0}={1}”, name, value); } TypeDescriptor lives in the System.ComponentModel namespace and is the API that Visual Studio uses to display your object in its property browser. It’s ultimately based on reflection (as any … Read more

Very simple log4j2 XML configuration file using Console and File appender

<?xml version=”1.0″ encoding=”UTF-8″?> <Configuration status=”INFO”> <Appenders> <Console name=”Console” target=”SYSTEM_OUT”> <PatternLayout pattern=”%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} – %msg%n” /> </Console> <File name=”MyFile” fileName=”all.log” immediateFlush=”false” append=”false”> <PatternLayout pattern=”%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} – %msg%n”/> </File> </Appenders> <Loggers> <Root level=”debug”> <AppenderRef ref=”Console” /> <AppenderRef ref=”MyFile”/> </Root> </Loggers> </Configuration> Notes: Put the following content in your configuration file. Name the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)