Quantcast
Viewing latest article 3
Browse Latest Browse All 4356

Linq

How would you convert this to use anonymous methods using visual cobol for visual studio 2017?  I am more interested in the delegates and the use of the linq join extension.  The property's I can get and convert.  I cannot figure out how to work the join expression using delegates for visual cobol .net.

List<State> states = new List<State>()
            {
                new State {SID = 1, SName = "Telangana", SCode = "+91", SAbbrevation = "TG"},
                new State {SID = 2, SName = "Texas", SCode = "512", SAbbrevation = "TS"},
            };

            List<Country> coutries = new List<Country>()
            {
                new Country {CID = 1, CName = "India", CAbbrevation = "IND"},
                new Country {CID = 2, CName = "US of America", CAbbrevation = "USA"},
            };

            var res = coutries.Join(states,
                delegate(Country a) { return a.CID; },
                delegate(State b) { return b.SID; },
                delegate(Country a, State b) { return new {a.CName, b.SName}; }).ToList();

        }

        public class State
        {
            public int SID { get; set; }
            public string SName { get; set; }
            public string SCode { get; set; }
            public string SAbbrevation { get; set; }
        }

        public class Country
        {
            public int CID { get; set; }
            public string CName { get; set; }
            public string CAbbrevation { get; set; }
        }


Viewing latest article 3
Browse Latest Browse All 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>