GetProperties() not returning the declared properties of a script, returning only inherited properties instead.

I am trying to get a list of the properties declared within the class but the best I seem to be able to do is to find the inherited members without any of the declared ones (This can be seen if using the below code but removing ‘BindingFlags.DeclaredOnly’). I would expect the below code to output the following:




Instead, what is returned is:



I’m hoping that someone will be able to set me right here.


using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;

public class Test123 : MonoBehaviour {

    public MonoBehaviour[] scripts;

    void Awake()
        PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
        for (int j = 0; j < properties.Length; j++)


scripts is not a property but a field. A property (in the sense of C# / .NET) is a set of two methods: a getter and a setter. A field is an actual data field. If you want to get the field of a class use GetFields instead of GetProperties