We help IT Professionals succeed at work.

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

Stacie
Stacie asked
on
115 Views
Last Modified: 2017-04-10
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

Comment
Watch Question

Developer
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Richard LeeSoftware Enthusiast
CERTIFIED EXPERT

Commented:
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.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions