I'm curious, whether is possible such trick in C#:
Basically speaking, in PHP what I do, is I assign an object variables
using simple loop:
class MyObject {
private $myObjVar;
private $anotherVar;
public function MyObject($a, $b) { $this->myObjVar = $a; $this-
>anotherVar = $b; };}
$myObject = new MyObject(123, "hello world!");
foreach($myObject as $oField =$oValue)
{
printf("%s = %s\n", $oField, $oValue);
/* That gives me an output of MyObject like:
myObjVar = 123
anotherVar = hello world!
*/
}
Is such loop possible in C#, anyhow? (Loop, or rather an object access
mode)
The second question is, directly connected with first one: Is it
possible to access an C# Object such way (PHP sample):
$varName = "myObjVar";
echo $myObject->{$varName};
// That will print out "123"
Anyway to do it in C#?
Thank you in advanced for any suggestions.
All the best,
Przemek M. Zawada