Book Image

Beginning C# 7 Hands-On ??? Advanced Language Features

By : Tom Owsiak
Book Image

Beginning C# 7 Hands-On ??? Advanced Language Features

By: Tom Owsiak

Overview of this book

Beginning C# 7 Hands-On – Advanced Language Features assumes that you’ve mastered the basic elements of the C# language and that you're now ready to learn the more advanced C# language and syntax, line by line, in a working Visual Studio environment. You'll learn how to code advanced C# language topics including generics, lambda expressions, and anonymous methods. You'll learn to use query syntax to construct queries and deploy queries that perform aggregation functions. Work with C# and SQL Server 2017 to perform complex joins and stored procedures. Explore advanced file access methods, and see how to serialize and deserialize objects – all by writing working lines of code that you can run within Visual Studio. This book is designed for beginner C# developers who have mastered the basics now, and anyone who needs a fast reference to using advanced C# language features in practical coding examples. You'll also take a look at C# through web programming with web forms. By the time you’ve finished this book, you’ll know all the critical advanced elements of the C# language and how to program everything from C# generics to XML, LINQ, and your first full MVC web applications. These are the advanced building blocks that you can then combine to exploit the full power of the C# programming language, line by line.
Table of Contents (35 chapters)
Title Page
Credits
About the Author
www.PacktPub.com
Customer Feedback
Preface

Manipulating an image


To start, in my c:\data folder, I have a file called lessonimage. As you can see in Figure 25.4.1, the writing on the Coke can is red and the background seems to be reddish-brown:

Figure 25.4.1: The image to be used for inverting colors at the pixel level in this chapter

What we will do is switch the colors around, so that the writing on the Coke can, for example, will become green, and you will learn how you can manipulate images at the individual pixel level.

Adding a button and an image control to the HTML

Open up a new project. Delete the two lines that begin with <div...; also delete the Label line this time. You don't need any of them.

Next, you need to insert a Button control into the <html> page. To do this, go to Toolbox, grab a Button control, and drag and drop it below the line beginning with <form id=.... Change the text on the first button to say Load.

Now you need to insert an image control into the <html> page. So, go back to Toolbox, grab...