---
title: "Dynamic Invocation with Reflection.Emit"
url: "https://osherove.com/blog/2003/5/26/dynamic-invocation-with-reflectionemit.md"
canonical: "https://osherove.com/blog/2003/5/26/dynamic-invocation-with-reflectionemit.html"
published: "2003-05-26T08:19:00"
updated: "2003-05-26T08:19:00"
tags: [".Net Quotations"]
author: "Roy Osherove"
description: "Reflection is just one of the areas I'd ilke to explore more of. This article is just one of the reasons I find this area cooler than most : Dynamic Invocation with Reflection.Emit . It shows you howe to create a method…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Dynamic Invocation with Reflection.Emit

By Roy Osherove May 26, 2003 In [.Net Quotations](https://osherove.com/blog/category/net-quotations)

**Historical article** · Originally published May 26, 2003; technical details may be outdated.

Reflection is just one of the areas I'd ilke to explore more of. This article is just one of the reasons I find this area cooler than most : [Dynamic Invocation with Reflection.Emit](http://www.ondotnet.com/pub/a/dotnet/excerpt/prog_csharp_ch18/index.html?page=9#dyn_inv_re) .

It shows you howe to create a method on the fly that iterates in a loop and sums up numbers. Although it's not what I'd do every time I'll need a loop, I'll bet there are some pretty cool applications for this 'feature'. One of them is a performance increase of 3000%.

## More in .Net Quotations

[All posts in .Net Quotations](https://osherove.com/blog/category/net-quotations)

- May 28, 2003

    ### [SP/Invoke -- Stored Procedure Invocation Code Generator for VB, C# and JScript.NET](https://osherove.com/blog/2003/5/28/spinvoke-stored-procedure-invocation-code-generator-for-vb-c.html)

- May 27, 2003

    ### [Good Stuff](https://osherove.com/blog/2003/5/27/good-stuff.html)

- May 15, 2003

    ### [One Cool Menu](https://osherove.com/blog/2003/5/15/one-cool-menu.html)

- May 13, 2003

    ### [MSDN Hands-On Labs](https://osherove.com/blog/2003/5/13/msdn-hands-on-labs.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
