There are almost as many ways to implement the command pattern as there are types of data to pass to it, and not all of them are correct. Follow along in Visual Studio as Jeremy McPeak shows you how to enable an object to issue a request to another object while remaining blind to the details of both the request and target object. Jeremy then demonstrates how to pass required data to the command’s constructor. Users with a knowledge of C# fundamentals and basic patterns will gain the tools needed to pass data to a command without violating the command pattern.

Continue learning about C# with Learning Paths.

Jeremy McPeak is a self-taught programmer who began his career tinkering with websites in 1998. He is the author of Beginning JavaScript, 5th Edition, JavaScript 24-Hour Trainer, and co-author of Professional Ajax, 2nd Edition. He also contributes to Tuts+ Code (, providing articles, video tutorials, and courses on JavaScript, C#, ASP.NET, and PHP. He is currently employed by an oil and gas company, building in-house conventional and web applications.

Article image: Screen from "How can I pass parameters to a command in C#?" (source: O'Reilly).