Recent Blogs

Mastering Google Drive API in C#: A Comprehensive Guide for Developers

Author: Sameer Saini Date Published: March 07, 2023

This blog provides a comprehensive guide for developers looking to use the Google Drive API in their C# applications. It covers various topics such as authentication, uploading and downloading files, searching, updating, deleting, and sharing files, working with folders, using the API with ASP.NET Core, handling errors, and best practices. By the end of the blog, developers will have a thorough understanding of how to effectively and efficiently use the Google Drive API in their C# projects.

Read More

Convert Byte To String In C#

Author: Sameer Saini Date Published: March 06, 2023

Converting a byte array to a string is a common task in C#, especially when working with data that has been encoded in bytes, such as image files or network packets. In this blog post, we'll explore several methods for converting byte arrays to strings in C#.

Read More

Convert Byte To Stream In C#

Author: Sameer Saini Date Published: March 06, 2023

In C#, you can easily convert a byte array to a stream using the MemoryStream class, which provides a stream backed by an in-memory buffer. This can be useful when working with APIs or libraries that require a stream as input, or when you need to manipulate the data in a byte array using stream-based operations. In this blog, we'll explore how to convert a byte array to a stream in C# using the MemoryStream class.

Read More

Convert Int to String in C#

Author: Sameer Saini Date Published: March 02, 2023

Converting an int to a string is a common task in C# programming. This process is useful when you need to display an integer value as text, concatenate integer values with other strings, or store integer values in a text file. In this blog post, we'll explore the different ways to convert an int to a string in C#.

Read More

Convert String To Datetime In C#

Author: Sameer Saini Date Published: July 28, 2022

This blog post will teach us how to convert a string to DateTime in C#. Let's say you have a datetime string with a date time value and now you want to perform some date calculations or checks or something else, you would need to convert this string to date in C#.

Read More

Check If String Is A Number In C#

Author: Sameer Saini Date Published: July 28, 2022

In this blog post, we will learn how to check if a string is a proper number or integer in C#. Let's say you have a code in which you are getting a age as a string from a database call and you want to check if this string is a number or not before you could use it, this is where this check would be handy.

Read More

Convert String To Float In C#

Author: Sameer Saini Date Published: June 12, 2022

In this blog post, we are going to learn how we can convert a string to float in C#. If you have a string that has a floating-point value or a double stored in it, and you want to convert the string to a float so that you can use it in your application.

Read More

Get Int Value From Enum In C# - Convert Enum To Int In C#

Author: Sameer Saini Date Published: June 12, 2022

In this blog post, we are going to learn how we can get an Int value from Enum in C#. As we know, An enumeration type (or enum type) is a value type defined by a set of named constants of the underlying integral numeric type.</p> <p>We can get the integral value of an enum and can use it inside our C# application.

Read More

Get The First Character Of A String In C#

Author: Sameer Saini Date Published: May 31, 2022

In this blog post, we are going to learn how we can get the first character of a string in C#. We will discuss 2 methods by which we can get the first character of a string. Just note that you should still check if the string is null or empty to avoid any runtime exceptions.

Read More

Convert List To Dictionary In C#

Author: Sameer Saini Date Published: May 31, 2022

In this blog post, we will learn how we can convert a list to a dictionary in C#. Let's say you have a list and you want to convert it to a dictionary so that you can have defined key value pairs so you can use them, this is where this conversion from a list to dictionary comes in handy.

Read More

Calculate Age From Date Of Birth (DateTime Birthdate) In C#

Author: Sameer Saini Date Published: May 31, 2022

In this blog post, we will learn how we can calculate the age of a person from their birthdate (birthday) in C#. To calculate the age of the person as of today's date, we need two variables, today's date and the birthdate(birth date) of the person for which we want to calculate the age.

Read More

Get File Size In C#

Author: Sameer Saini Date Published: May 22, 2022

In this blog post, we will see how we can get the size of a file in C#. To get a file size in C#, we have to use the Length property on the FileInfo.

Read More

Convert String To Hex In C#

Author: Sameer Saini Date Published: May 22, 2022

In this blog post, we will see how we can convert a string to hex in C#. We will look at 3 ways by which we can easily convert a string to hex in C#.

Read More

Char Array To String In C#

Author: Sameer Saini Date Published: April 06, 2022

In this blog post, we will learn how to convert a <b>Char Array To String</b> in C#. A char array is an array of character types. That means they hold a single character value in each of its elements.

Read More

Wait For X Seconds In C# - Add Delay In C#

Author: Sameer Saini Date Published: March 30, 2022

In this blog post, we will learn a couple of ways by which we can wait for X seconds in C# and delay execution. There can be a few use cases for adding a delay or for waiting for X seconds before you resume execution of your code in C# such as printing records back to the console, adding an explicit delay to mock or stub a slow running server or a backend service, etc.

Read More

C# Tab Character - Add Tab In String C#

Author: Sameer Saini Date Published: March 28, 2022

In this blog post, we will learn how we can add a tab in string in C#. There are a lot of places in your code where you would feel the need to add a tab character in C#.

Read More

C# Multiline String - Add New Line In String C#

Author: Sameer Saini Date Published: March 26, 2022

Let's learn to create a multiline string in C#. For readability purposes, sometimes we have to split a string into a multiline string in C#. To our luck, there are several ways by which we can have multiline strings in C#.

Read More

C# Double Question Mark Operator - Null-Coalescing Operator C#

Author: Sameer Saini Date Published: March 26, 2022

If you are reviewing a C# code and you've come across a double question mark operator (??), you must be wondering what does this double question mark operator does in C#. In this blog post, we will learn what this double question mark operator does and we will also see a few usages of this operator in some code examples.

Read More

C# Array Length - Get Length Of Array Using Array.Length() Property

Author: Sameer Saini Date Published: March 26, 2022

In this blog post, we will learn how we can get the <b>length of array</b> in C#. This is really easy and we will see how we can use the property on any array that you want to get the length or the count of elements for. Let's see how we can get the length of the array using a code example.

Read More

3 Ways To Convert An Array To List In C#

Author: Sameer Saini Date Published: March 25, 2022

In this blog post, we will convert an <b>Array To List in C#. If you are dealing with Arrays in a code base, you may end up converting that to a much more powerful List in C# for several reasons. For one, it's much easier to append items to a list than to an array and you can use the power of Linq in lists easily.

Read More

Pass Function As Parameter Using C#

Author: Sameer Saini Date Published: March 24, 2022

In this blog post, we will learn how we can pass a function as a parameter in C# or a method as a parameter in C#. Pass Function As A Parameter To Another Function In C# Using Func Delegate.

Read More

Get List Length C# - Get Count Of Elements In A List C#

Author: Sameer Saini Date Published: March 24, 2022

In some scenarios, we need to get the count of elements in a list in C# or the length of a list in C#. These are the cases where we need to check if the length or the number of elements in the list is greater than or less than some number.

Read More

Convert Stream To Byte Array In C#

Author: Sameer Saini Date Published: March 24, 2022

In this blog post, we will see how we can convert a stream to byte array in C# using the .ToArray() method available on the MemoryStream class. We will use the .ToArray() method available on the MemoryStream class and convert stream to byte array.

Read More

Build REST APIs with ASP.NET CORE WEB API & Entity Framework

Author: Sameer Saini Date Published: March 24, 2022

This is a complete guide to creating a highly scalable ASP.NET CORE RESTful WEB API using .NET Core Version 6 (.NET 6), Entity Framework Core and SQL Server database. This course is for all skill levels and is best suited for beginners and intermediate developers who have gained knowledge in C# and ASP.NET framework and want to use their skills to learn highly scalable WEB APIs using REST principles. In this WEB API course, we will use ASPNET Core Version 6 (also known as .NET 6) and create a RESTful WEB API.

Read More

How To Initialize Array In C#

Author: Sameer Saini Date Published: March 24, 2022

As we know an Array in C# is a collection of objects. This Array could be of any type, for example, a string array or an int Array. Before we can use an Array and do something with it like assign values or append values or iterate on it, we need to initialize the array.

Read More

Create ASP.NET Core WEB API CRUD With Angular UI

Author: Sameer Saini Date Published: March 15, 2022

In this blog post, we will create an ASP.NET CORE WEB API CRUD Application With Angular CRUD operations. We will use ASP.NET CORE 6 or .NET 6 to create our WEB API and we will connect our API to an ANGULAR 13 application. This Angular 13 application will perform CRUD operations on the ASP.NET CORE WEB API.

Read More

Get Random Number Between 1 and 100 C#

Author: Sameer Saini Date Published: March 07, 2022

In this blog post, we will get a random number between 1 and 100 using C#. We will use the Random class that C# provides us. We will instantiate the <b>Random</b> class and then provide a range to the .Next() method.

Read More

Add Or Append Item To An Array C#

Author: Sameer Saini Date Published: March 06, 2022

In this post, we will add to an array in C#. Adding an element to array means to add a new item or an element of type to an existing array. In C#, we have a few different options to add or append to an existing array.

Read More

Split String In C# - String.Split() Method In C#

Author: Sameer Saini Date Published: March 05, 2022

In our day-to-day scenarios, we sometimes end up in a scenario where we have to split a delimited string to a list. If you are using the C# language, splitting a string is an easy task. In this blog post, we will learn how we can split a string in C# using the <b>string.Split()</b> method and we will also use a delimiter such as a comma or a space to split the string into a list or an array.

Read More

Iterate An Enum In C# - Looping Through All Enum Values In C#

Author: Sameer Saini Date Published: March 02, 2022

We often find a use case where we have to iterate through the values of something to get the job done. This iteration of looping can be for some calculations or display stuff, but we always iterate on lists or arrays and get data out of each item in that list or array. In this blog post, we will use loops, but not on a list or array, we will iterate an enum today.

Read More

Join An Array In C#

Author: Sameer Saini Date Published: March 02, 2022

In this blog post, we will learn how we can join an array in C#. Joining an array means joining the values of the array using a delimiter. When we join an array in C#, we loop through all the values and insert a delimiter value (if any) to join and make the result. For example, an array ["John", "Julie", "Sameer"] would be joined to make a string "John,Julie,Sameer" if the delimiter was a comma value. How do we achieve this? In C#, we use the Join() method that is available to us in the sealed class String.

Read More

Find An Item In List Using LINQ - C#

Author: Sameer Saini Date Published: March 02, 2022

Have you been in a situation where you have a list and you have to find an item in the list? C# offers us an easy way to find an item in a list using the .Find() method. The Find() method searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire List.

Read More

Convert An Enum To String In C#

Author: Sameer Saini Date Published: March 02, 2022

In this blog post, we will convert an Enum to string in C#. An enumeration type (or enum type) is a value type defined by a set of named constants of the underlying integral numeric type. We can convert an enum to a string using the .ToString() method on the Enum.

Read More

Empty GUID In C# - Create Or Get An Empty GUID In C#

Author: Sameer Saini Date Published: February 28, 2022

In a C# ASP.NET website or application, sometimes we need to check if a GUID being passed is empty or not. Sometimes, we also need to generate an empty GUID for some different use cases. In C#, we can easily create an empty or default GUID using the GUID static class that the system namespace provides us. We can also compare a GUID value to check whether it's an empty GUID.

Read More

How To Read Text File Using C#

Author: Sameer Saini Date Published: February 28, 2022

If you want to learn how you can read text from a text file using C#, you have come to the right blog post. In this one, we will go step by step and see how easily we can read a text file using C#

Read More

Get Random Number Using C#

Author: Sameer Saini Date Published: February 28, 2022

C# gives us a class called Random that gives us a really easy way to create random numbers in between a range of 2 numbers (min and max). If no range is provided, the integer min and integer max values are taken. Note: The returned number or integer can be greater than or equal to min value but less than max value.

Read More

Get Current Directory In C#

Author: Sameer Saini Date Published: February 28, 2022

There are a few ways in which we can get the current directory of the application using C#. All of the below are running for a console application created using .NET 6 and returns the current directory the application is running under.

Read More

Delete A File If Exists Using C#

Author: Sameer Saini Date Published: February 28, 2022

Sometimes we have a delete a file or create a new one but we are just not sure if there is already a file that exists? In such a case, it's good practice to check if the file exists, and if it does, then delete the file.

Read More

Add Items To List C#

Author: Sameer Saini Date Published: February 22, 2022

A list represents a collection of strongly typed objects. This can be a list of integers, a list of strings, or a list of complex types. A list in C# is an easy way to maintain a collection of similar types and then using the functions that C# provides you can easily iterate on that list if you need to. There will be numerous use cases when you would need to add a new item to a list dynamically. For example, if you have a list of years that are from 2000 to 2020, now it's time to add the next 10 years to that list. You would need to dynamically add items to the list so that you can use them.

Read More