anonymous delegate class object

//////////////////////////////////////////////////////////
The code example below show you how to use anonymous delegate
//////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Text;

namespace YummyYummy
{
class Program
{

static void Main(string[] args)
{
doStuff();
}

private static void doStuff()
{
List _list = new List();
List _subList;

_list.Add(addClientInfo("AAA", "1111"));
_list.Add(addClientInfo("BBB", "2222"));
_list.Add(addClientInfo("CCC", "3333"));
_list.Add(addClientInfo("AAA", "4444"));

string _targetSearchString = "AAA";

ClientSessionEntity _client = _list.Find(delegate(ClientSessionEntity _entityA)
{
return _entityA.transactionId.Equals(_targetSearchString);
});

////////////// You will get an object with the "AAA" //////////////

_subList = _list.FindAll(delegate(ClientSessionEntity _entityA)
{
return _entityA.transactionId.Equals(_targetSearchString);
});

////////////// List of object with the "AAA" //////////////

Console.ReadLine();


}

private static ClientSessionEntity addClientInfo(string _transID, string _threadId)
{
ClientSessionEntity _client = new ClientSessionEntity();
_client.transactionId = _transID;
_client.threadID = _threadId;
return _client;
}

}
}

Comments

Popular posts from this blog

OpenCover code coverage for .Net Core

Using Custom DLL with IronPython / Scripts

ionic2 cordova build android - Unable resolve gradle 2.2.3