ComplexProperties with Reflections I have used reflection for divide the complex property. For example, if I bind A.B[0], CustomerName means CustomerName is returned. Can anyone help to reduce the code?

var itemproperties = view.GetItemProperties();                

if (itemproperties != null)
{
    if (propName.Contains("."))
    {
        string actualproperty = propName;
        string[] propertyNameList = propName.Split('.');
        int complexPropertyCount = propertyNameList.Count(), index = 0;
        bool isArrayproperty = actualproperty.IndexOf('[') != -1;

        if (isArrayproperty)
        {
            string strindex = actualproperty.Substring(actualproperty.IndexOf('[') + 1, actualproperty.IndexOf(']') - actualproperty.IndexOf('[') - 1);
            index = Convert.ToInt32(strindex);
            string property = actualproperty.Substring(0, actualproperty.IndexOf('['));
            for (int i = 0; i &lt; propertyNameList.Length; i++)
            {
                if (propertyNameList[i].Contains('['))
                {
                    if (property.Contains("."))
                        property = propertyNameList[i].Substring(0, propertyNameList[i].IndexOf('['));
                    propertyNameList[i] = property;
                    break;
                }
            }
        }

        for (int iterator = 0; iterator &lt; complexPropertyCount - 1; iterator++)
        {
            var tempProperyDescriptor = itemproperties.Find(propertyNameList[iterator], true);
            if (tempProperyDescriptor != null)       // Fix for SD 8318
            {
                record = tempProperyDescriptor.GetValue(record);
                itemproperties = TypeDescriptor.GetProperties(record);
            }
        }

        actualproperty = propertyNameList[complexPropertyCount - 1];

        if (isArrayproperty)
        {
            IList arrayList = ((IEnumerable)record) as IList;

            foreach (var item in arrayList)
            {
                var propertyInfo = item.GetType().GetProperty(actualproperty);

                if (propertyInfo == null)
                    return null;
                if (arrayList.IndexOf(item) == index)
                {
                    return propertyInfo.GetValue(item, null);
                }
            }
            return null;
        }

        var propertyinfo = record.GetType().GetProperty(actualproperty);

        if (propertyinfo == null &amp;&amp; view is CollectionViewAdv)
        {
            var sourceType = (view as CollectionViewAdv).SourceType;
            if (sourceType != null &amp;&amp; typeof(ICustomTypeDescriptor).IsAssignableFrom(sourceType))
                return itemproperties.Find(actualproperty, true).GetValue(record);
            return null;
        }

        if (!itemaccessor.ContainsKey(propName))
        {
            PropertyAccessor accessor = new PropertyAccessor(propertyinfo);
            itemaccessor.Add(propName, accessor);
            var val = accessor.GetValue(record);
            return val;
        }
    }

    if (record == null)
        return null;
    return itemaccessor[propName].GetValue(record);
}

return null;
Considering that you simply return null if the itemproperties are null, do that immediately:

if (itemproperties == null)
{
    return null;
}

if (propName.Contains("."))
{
}


That way you don't need to have 80+ lines inside an if.

The same is probably true for your next check -- if (propName.Contains(".")) -- but since you don't provide us with enough information I cannot help you there: where does propName come from? Where does record come from?

I see duplicate code:

actualproperty.Substring(0, actualproperty.IndexOf('['));
propertyNameList[i].Substring(0, propertyNameList[i].IndexOf('['));


Shouldn't that be converted to a method call?