I need to write all the primitive properties of a C # object regardless of how many "levels" I enter into those objects.
I have the following object in Javascript:
var objeto = {
propriedade:{
valor:42
},
atributo:"foo"
}
Then to access all properties of it recursively, I do the following:
function PrintAllProperties(obj){
for(var prop in obj){
if(typeof obj[prop]==="object")
PrintAllProperties(obj[prop]);
else
console.log(obj[prop]);
}
} PrintAllProperties(objeto);
This output is formed by all properties with primitive value regardless of the amount of levels that had to be accessed from that "parent" object ( example working )
How to do this in C #?