Legal Notice
The opinions expressed herein are my own personal opinions and do not represent my employer’s view in anyway.Top Posts
- C# DateTime to UNIX timestamps
- C# Use HttpClient to GET JSON from API endpoint
- C# JWT Token Get Expiry Timestamp
- Serialization and deserialization of 'System.IntPtr' instances are not supported. Path: $.TargetSite.MethodHandle.Value
- C# Authorization in .NET Core API's using Attributes, TypeFilterAttribute and IAuthorizationFilter
- .NET API CORS: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header.NET API
- C# Calculate Week Number from DateTime
Archive
Meta
Tag Archives: c#
C# Marking Deprecated Code As Obsolete
If a certain piece of code is no longer relevant or needed, or if it’s no longer maintained, you can mark it as obsolete. Use the [Obsolete] tag to mark the code. You can mark a function: Or you can … Continue reading
Posted in .net, .NET Core, c#, General .NET
Tagged Attribute, c#, Deprecated, Deprecating, Obsolete
Leave a comment
C# Game Of Life
The Game Of Life is a cell life simulator devised by the Cambridge mathematician John Conway. The simulator serves as an excellent coding example to learn new programming languages. The rules are simple. You have a grid in a predetermined … Continue reading
Posted in .net, .NET Core, c#, General .NET
Tagged Array, c#, Game of Life, Grid, Simulation
2 Comments
C# Connect to 2 or more databases using a Datacontext
This is more of a design pattern than it is a requirement. I use this technique when my application grows in size. When my application needs to connect to 2 or more databases, I use this encapsulation method to allow … Continue reading
Posted in .net, .NET Core, c#, General .NET, Microsoft Azure
Tagged .net, asp-net-core, Azure, c#, Dapper, Database, Managed Identity, programming, software-development, SQL, Table
Leave a comment
C# SqlBulkCopy insert a list of objects
The SqlBulkCopy class is able to bulk insert data from anything that comes from a DataTable or can be read using a SqlDataReader. So what do you do if you have an array of objects? You have to convert the … Continue reading
C# Convert array of objects into a DataTable
This extension method lets you convert an array of objects into a DataTable. DataTables are used for SQL inserts. This solution is not mine, in fact it has been copied so many times that I don’t know who came up … Continue reading
C# ‘SHA256Managed’ is obsolete: ‘Derived cryptographic types are obsolete. Use the Create method on the base type instead.’
So my code gives me this warning: Warning SYSLIB0021 ‘SHA256Managed’ is obsolete: ‘Derived cryptographic types are obsolete. Use the Create method on the base type instead.’ The code that warns me are: The reason is that SHA256Managed, SHA512Managed, SHA1Managed and … Continue reading
Posted in .net, .NET Core, c#, General .NET
Tagged c#, cryptography, hash, SHA, SHA256, SHA512
Leave a comment
Error CS0121: The call is ambiguous between the following methods or properties: AddApplicationInsightsTelemetryProcessor
So I wanted to add a ITelemetryProcessor to my project. I created a DependencyTelemetryFilter and applied the filter as I always do: But this throws an Error CS0121: The call is ambiguous between the following methods or properties error: The … Continue reading
Posted in .net, .NET Core, c#, General .NET, Microsoft Azure
Tagged Application Insights, c#, ITelemetryProcessor, Worker Service
Leave a comment
C# .net Swagger API Versioning – Show versions in your Swagger page
So, Swagger does in fact support versioning in the interface. You just need to do it right, and remember to apply all the attributes and methods. First of all, versioning an API is a standard thing, and will help your … Continue reading