Link to home
Start Free TrialLog in
Avatar of Stacie
StacieFlag for United States of America

asked on

Trying to understand what this mean...types(lstTypes[i].AvailableDatatype)

I'm having a hard time understanding this simple line of

 : types(lstTypes[i].AvailableDatatype);

Open in new window



using System;
using System.Collections.Generic;

namespace ConsoleApplicationTest
{
    class Program
    {
        static void Main(string[] args)
        {

            List<DotNet> lstTypes = new List<DotNet>();
            DotNet bltypes = new DotNet();
            bltypes.AvailableDatatype = "bool";
            lstTypes.Add(bltypes);


            DotNet strTypes = new DotNet();
            strTypes.AvailableDatatype = "string";
            lstTypes.Add(strTypes);

            DotNet intTypes = new DotNet();
            intTypes.AvailableDatatype = "int";
            lstTypes.Add(intTypes);

            DotNet decTypes = new DotNet();
            decTypes.AvailableDatatype = "decimal";
            lstTypes.Add(decTypes);


            types += x =>
            {
                Console.WriteLine(x);
                Console.ReadLine();
            };

            for (int i = 0; i <= lstTypes.Count - 1; i++)
            {
                types(lstTypes[i].AvailableDatatype);
            }




        }

        static event Action<string> types;



    }


    public class DotNet
    {
        public string AvailableDatatype { get; set; }
    }


}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Nitin Sontakke
Nitin Sontakke
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I would recommend researching the following:

  • Events including Subscribing & Unsubscribing
  • Action & Func
  • Lambda expressions

This, including the answer above will help you understand what is going on.