Definition:
public void showObjProperties( object myObject ) {
System.ComponentModel.PropertyDescriptorCollection objProperties = System.ComponentModel.TypeDescriptor.GetProperties( myObject );
string strTmp = "";
string strType = myObject.GetType( ).ToString( );
for ( int i = 0; i < objProperties.Count; i++ ) {
strTmp += strType + "." + objProperties[i].Name + Environment.NewLine;
//strTmp += strType + "." + objProperties[i].Name + ": " + objProperties[i].GetValue( myObject ).ToString( ) + Environment.NewLine;
}
throw new Exception( "Props: " + Environment.NewLine + strTmp );
}
Calling code:
String[] aryString = new String[] { "test1", "test2", "test3" };
showObjProperties( aryString );
Results:
Props:
System.String[].Length
System.String[].SyncRoot
System.String[].Rank
System.String[].IsReadOnly
System.String[].IsFixedSize
System.String[].IsSynchronized
System.String[].LongLength
2 comments:
Thank you, dude, this was VERY useful.
Glad I could help.
Post a Comment