Introduction
Hi Everyone. Today, I would like to share information about the Anonymous Method.
Description
The name itself describes it as "Anonymous". It means a method that does not have any name. We need not specify any return type for Anonymous method. For your understanding, I will give one small example, as shown below.
Example
- Delegate(Student s).
- Class student {
- Public int Id {
- get;
- set;
- }
- Public string Name {
- get;
- set;
- }
- }
The class student has 2 entities - Id, Name.
- Delegate bool IsCheck(Student s)
- Class student _Extend {
- List < student > objstudents = new list < student > () {
- New student {
- ID = 1, Name = "Vetri"
- }
- };
- }
In the above class, I described the list which is defined by student type. Now, I need to query the list. The best option is LINQ. I will query the list by standard query or method.
- IsCheck objChk = delegate(student s) { return s.id>=1;};
I created the object for delegate and queried the list and returned the boolean value.
Conclusion: So, this was a small example of Anonymous method.