This article is intended to show two programming lessons for beginner programmers.

First, it shows how to combine object arrays, simple user-defined object classes, properties, and simple code, to create OOP (Object Oriented Programming) applications with Visual Studio.
Secondly, it shows how to use simple LINQ queries with Lambda functions, to quickly search a user-defined object array.

Arrays in VS can be arrays of primitive types (Integer, Byte, Boolean etc.), but it's possible to create an array of just about any type you can imagine. A user-defined class typically contains Properties and Public or sometimes Private Methods. In the case of the example programs there are two user-defined classes - ElementDetails, which contains (from each element) the AtomicNumber, the Symbol, the Element (name), the [Type] (the Element's group), and finally the Image Property, which actually returns a dynamic Bitmap created on the fly in the Property Getter..
The [Type] Property could have been a String representing the name of the group, but it was advantageous to store two Properties related to the Group - the name, and a color. So, the return type of the Type Property is ElementType, which is the second of the core classes used.

LINQ combined with Lambda gives great results from minimal code. It is possible to query the user-defined array on any of the Properties to retrieve either one element, or a group of elements.


The examples are provided in both VB.Net 2017 and C# 2017, and available to download here.


Name:  15-12-2017 00.30.22.png
Views: 492
Size:  5.8 KB