I have something like this:
public class Foo
{
    public Bar[] Bars{get; set;}
}
public class Bar
{
    public string Name{ get; set; }
}
I start reflecting:
PropertyInfo propertyInfo = typeof(Foo).GetProperty("Bars");
so far so good. I want to reflect deeper:
Type type = _propertyInfo .PropertyType; // this gives me that the type is Bar[]
The type is Bar[], but it is not possible to reflect on type to开发者_如何学运维 look for property Name.
Is there a way to figure out the trype without the array? Or another way to find the single type of Bar?
if (type.HasElementType)
    Console.WriteLine(type.GetElementType().Name);
I wrote the HasElementType because I'm guessing you are also going to need to figure out if your element is an array.
type.GetElementType().Name
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论