English 中文(简体)
2. 如何检查内产物
原标题:How to Check inner class properties

某些类别

public class ClassA
{
    public string Name    { get; set; }
    public string Color   { get; set; }
    public ClassB ClassB_ { get; set; }


    public class ClassB
    {
        public string Name { get; set; }
        public float  Age  { get; set; }
    }
}

现在,我想要印刷,以控制A级的所有公共财产,以便使用这一工具。

(有些参数是该方法得到并打印其所有特性......)

 var allProp = obj.GetType().GetProperties();

但是,当我的申请看见A类的B类物品时——即还要印刷所有的B类财产,而且我不知道如何在操作时间知道B类是等级的,而不是原始的物体,以及怎样在操作时间上能够打印所有B类财产?

最佳回答

颁布这一法典:

Type type = Type.GetType("ClassA+ClassB");
var allProp = type.GetProperties();

如果需要动态的类型名称,则试图使用下一个代码:

string fullname = typeof(ClassA.ClassB).FullName;
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签