如何获取包含特定类对象的对象。反映 [英] how to get an object which contain an specific class object. reflect
问题描述
。我有一个B类实例对象B1。
还有另一个struct c's B类财产也是参考B1。 例如c.Bproperty = B1。另一个结构 类  B属性也是参考B1 现在,我得到对象B1,我想得到哪个struct实例有
属性引用B1,我该怎么办?我想我可以使用反射。
谢谢
< blockquote>
嗨cindycluck,
感谢您发布此处。
对于您的问题,请尝试以下代码。如果我误解了你想要的东西,请随时与我们联系。
public struct C
{
B B1;
public void Method()
{
B1.Bproperty =" hello" ;;
}
}
class B
{
private string property =" NAME" ;;
public string Bproperty
{
get {return property; }
set {}
}
}
最好的问候,
Wendy
for example. I have an class B instance object B1.
there is another struct c's class B property also is reference B1. such as c.Bproperty = B1. And another struct d's class B property also is reference B1 Now, I get the object B1, and I want to get which struct instance has property reference the B1, what should I do? I think I can use reflect.
thank you
Hi cindycluck,
Thank you for posting here.
For your question, Please try the code below. If I misunderstand what you want, please feel free to contact us.
public struct C { B B1; public void Method() { B1.Bproperty = "hello"; } } class B { private string property = "NAME"; public string Bproperty { get { return property; } set { } } }Best Regards,
Wendy
这篇关于如何获取包含特定类对象的对象。反映的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!