Building strings in memory using the string concatenation operator, the plus sign (+) in C#, causes a few problems. The string class is immutable which means that once a string is created in memory, the size and location of this string value cannot grow or shrink. Thus, when you use the concatenation operator you are creating a new string in a new location in memory and telling the .NET garbage collector to throw away the old string value. This causes the garbage collector to perform extra work and slows down your application. This is where using the StringBuilder class can help you out. In this blog post you learn the basics of using the StringBuilder class.)
This blog series has shown you how to upload files using ASP.NET Core. You have learned how to style the HTML file upload control and how to upload a file to the server. You uploaded additional information with the file using a view model class. You checked for just specified file types and validated that only those types were uploaded. Finally, you uploaded images and created thumbnail images. In this blog post you are going to set a limit on how large a file can be uploaded.)
Previously in this blog series, you learned to style the HTML file upload control, upload a file to the server, use a view model class to upload additional information with the file, and to validate the type of files that can be uploaded. In this post you learn to upload a photo and create a thumbnail version of that photo. The thumbnail version of a photo can be used when displaying a list of photos to a user. Using a smaller version of the photo keeps your web pages smaller and faster to load. You can then allow the user to click on one of the photos to display the large version.)
Previously in this blog series, you learned how to style the HTML file upload control and how to upload a file to the server. You then learned to upload additional information with the file using a view model class. In this blog post you learn to set the file upload control's dialog to just look for certain file types. You also learn how to validate the file that is uploaded to make sure only certain types are allowed to be uploaded.)
In part 1 of this blog post series, you learned how to style the HTML file upload control and how to upload a file to the server. In this post you are going to see how to upload additional information with the file using a view model class. You are going to start out using a very simple view model class just so you get the basics down. Then you use a file upload base view model class and inherit from this class to upload a file and copy it to the file system on the web server. This prepares you to inherit from this base class later and store the uploaded file to a SQL Server or other type of database.)
User's frequently want the ability to upload files to a website. If you are using ASP.NET Core/8 with MVC and Bootstrap 5.x, you know that the normal file upload control does not look like the rest of your Bootstrapped controls. In this blog post you are going to learn how to modify the default look and feel with a couple of other looks to make the file upload control match the rest of the bootstrap styled HTML. In addition, you learn the very basics of uploading a file to a server.)
In this blog post you learn how to compare two lists of data and either add to or extract certain data from the lists. You also perform a check to determine if the data contained in the two lists is the same or not.)
In this blog post you learn how to apply some iteration methods to a collection of data. The ForEach() method allows you to iterate over the entire collection and apply an expression to each object. The Skip() methods allows you to bypass a certain amount of objects at the beginning of a collection. The Take() methods allows you to only take a certain amount of objects from the beginning of a collection.)
In this blog post you are going to learn how to use various aggregate methods of LINQ to count, sum, get a minimum and maximum value and get an average value within a collection of data.)
In this blog post you are going to learn how to join two collections together using both inner and outer joins. You are also going to see how to group data by a specific column such as size and view the different products that fall within that size. In addition, you learn a few different methods for retrieving distinct values from a collection.)
In this blog post you are going to learn how to sort the data using the orderby keyword and the OrderBy() method. Sorting data in a descending order and sorting on two different properties is also explored. The where keyword and the Where() method are used to filter data in a collection based on a criteria you specify. There is a myriad of other methods you are going learn about for searching for data in a collection including Find, First, Last and Single. Finally, you learn the methods used to see if a collection contains a certain value.)
Language Integrated Query (LINQ) is a query language built into the C# and Visual Basic languages. This query language allows you to write queries against any collection that supports the IEnumerable or IEnumerable<T> interfaces. LINQ helps you eliminate loops in your code which are typically slow to execute. LINQ also means you have one unified language for querying any type of collection. Type-checking of objects is supported at compile time which means less chance of errors and you also get IntelliSense.)
Most programmers know that if you have anything other than a two table join, you should not use LINQ with the Entity Framework (EF). If you do, the resulting SQL that is submitted by EF to SQL Server tends to be inefficient. This can cause big performance problems in your application. It is better to put complicated JOIN statements into stored procedures and call the stored procedures. However, calling stored procedures using EF can be tedious. This article describes a set of wrapper classes that helps you to simplify these stored procedure calls.)
In the last blog post you learned to read songs from an exported iTunes XML file. If you have been using iTunes for a long time and have deleted songs, merged songs from other libraries, moved your library from one computer to another, then you may not know it, but there could song files on your hard drive that are no longer in the iTunes library. This blog post shows you how to locate those missing files. To follow along with this blog post, read and follow the instructions in the first blog post on reading songs from iTunes.)
Have you ever wanted to retrieve the list of songs from your iTunes library? Getting songs from iTunes is not easy. In fact, since Apple stopped supplying their COM component for reading from their iTunes library, about the only way to get song data is to export the library into an XML file, then parse the XML. In this blog post you are going to learn to parse the XML using the classes contained in the System.Xml.Linq namespace.)
Yes, we all know reflection is slow, but sometimes it is necessary to use it to satisfy a business requirement in our application. Just like anything, there is a right way and a wrong way to use reflection. Microsoft has made significant improvements in performance over the years for getting and setting properties. This blog post shows you the slow and the fast ways of using reflection. )
Extension methods allow you to add your own custom method to an existing type. This blog posts shows you how to create extension methods.)
Prior to .NET 2.0 when you needed a single method to work with different data types the only way to accomplish this was to pass an 'object' data type to that method. Working with the object data type introduces performance problems and bugs that can occur at runtime. The alternative is to create a new method for each data type that you wished to work with. This blog post introduces you to C# Generics.)