Sample scenario:
public class MyClass
{
string sample1 = "Hello";
string sample2 ="sample1"
}
Console.WriteLine(sample);
//This should write 'Hello' in console.
The actual scenario is as follows :
public class Sample1
{
string variable1=1;
}
public class Sample2
{
Sample1 sample;
}
public class Access
{
public void getData(Sample2 s)
{
string return="s.sample.variable1"
Console.Writeline(return)
//This should return '1'(value of 's.sample.variable1')
}
I have tried my level best to understand the concept of reflection and also some sample code available in other similar posts, but nothing worked.
Aucun commentaire:
Enregistrer un commentaire