Posts

Showing posts from August, 2021

Donate

Generic Method With BitConverter.GetBytes() Throws Error: CS1503 Argument 1: cannot convert from 'T' to 'bool'

Image
Hello And Good Day! There was a post in VBForums Generic Method with BitConverter.GetBytes problem on how to pass a T variable without causing the issue CS1503 Argument 1: cannot convert from 'T' to 'bool' private static byte [] GetBytes<T> (T valu) { var bytes = BitConverter.GetBytes(valu); if (BitConverter.IsLittleEndian) Array.Reverse(bytes); return bytes; } Since Generic Constraints for a numeric types isn't available at this time, I attempted to solve this issue by checking the type of T and then perform the conversion explicity. private static byte [] GetBytes<T>(T value ) { byte [] bytes; ushort val1; uint val2; Type t = typeof (T); if (t == typeof ( ushort )) { val1 = Convert.ToUInt16( value ); bytes = BitConverter.GetBytes(val1); } else if (t == t...

How To Create Or Generate PDF Reports Or Files Using DinkToPDF in .NET 5 or .NET Core Console Application

Image
Good day! In this tutorial, I will demonstrate on how to create or generate PDF reports or files using DinkToPDF in .NET 5 or .NET Core Console Application. This library is a C# .NET Core wrapper for wkhtmltopdf library that uses the Webkit engine to convert HTML files or page to PDF and was developed by 'rdvojmoc Rok Dvojmoč' from Slovenia. To begin with lets start by establishing the project structure. Project Structure 1. Create a .NET 5 or .NET Core Console Application Project. 2. Add DinkToPDF and Unity packages using NuGet. 3. Copy the libwkhtmltox (dll, dylib and so) files from DinkToPDF and attach those files to your project. Make sure to set the Copy to Output Directory attribute of those files to Copy Always . Note that there are two versions for these files,32 and 64 bit. 4. Create three folders to the project and in each folder add the empty classes or interface shown in step #6. 5. Add an empty html file called ReportTemplate inside the project and set...

Using Microsoft.Extensions.DependencyInjection In .NET 5 or .NET Core Console Application

Image
Team, Here's how to incorporate the Microsoft.Extensions.DependencyInjection namespace and it's ServiceProvider class in a .NET 5 or .NET Core Console Application project. If you're an ASP.NET Core MVC developer, you might recognize how it is applied in Startup.cs for Dependency Injection specifically ConfigureServices() method wherein the AddTransient() method is utilized to map an interface class and it's implementation type. To begin with, lets by creating a .NET 5 Console application project and follow the steps below. Project Setup 1. Add the Microsoft.Extensions.DependencyInjection package to your project via NuGet. 2. Create three folders, new classes and interfaces based from the image below. Models Add two model classes specifically Employee and Product with three properties for each class. Product.cs public class Product { public int ProductCode { get ; set ; } public string ProductName { get ; set ; } public double Prod...

Sharkoon SKILLER SGS2 Gaming Chair Product Review

Image
Team, A week ago,I decided to purchase a gaming chair at a local computer shop in one of the malls here in Cebu since the piston of my old office chair does not work anymore. I did canvass at several stores but I'm not amazed by the brands that they were selling.While most of the chairs' upholstery that were presented to me were made of leather, the Sharkoon SKILLER SGS2 Gaming Seat was made of fabric and the price is just within my budget. That's why I decided to purchase this item. The main features of Sharkoon SKILLER SGS2 Gaming Chair based from the main website Sharkoon SKILLER SGS2 Gaming Chair are: A. Breathable and Supple - which describes the upholstery that is entirely made of soft fabric. B. Versatility through Adjustability - denotes the adjustable backrest, ergonomic posture, 3D armrest and seating height. C. Comfortable Extras - these extras include suspension and tilt control system, large 60 mm wheels and a backrest which can be reclined and locked ...

Donate