How to start, stop, and restart Windows Services using C#

Windows Services are a core part of the Windows Operating System which is responsible for creating and managing the long-running processes. In this article, we will learn how to start, stop, and restart a windows service using C# programming language. Starting a Windows Service using C# This method below will start the windows service “aspnet_state”... » read more

C# String Format for DateTime Overview

In this tutorial, we are going to use the method String.Format to format string for DateTime DataType. Format a String for DateTime using C# Example: DateTime dateTime = DateTime.Now; String date; date = String.Format("Date & Time Format: {0}", dateTime); Console.WriteLine(date); date = String.Format("Date Only Format: {0:D}", dateTime); Console.WriteLine(date); date = String.Format("Time Only Format: {0:T}", dateTime);... » read more

String.Format in C# for Decimal

In this article, we will learn how to use the String.Format function to format a string into Decimal number format. How to format a Double in C# using String.Format For example, if you have to format a number up to two decimal places, use a pattern that specifies two zeros after point such as 0.00.... » read more

C# FileStream: open, read, write files in C#

In .NET Framework, the System.IO namespace contains classes and functions that are used for file-related functionality, such as creating, reading, writing, updating, or closing a file. In this article, we will look at the FileStream class and its importance in WinForms applications. Using FileStream Class in C# for file operations It is a recommended programming... » read more

Introduction to File attributes in C#

In this article, we will learn about file attributes in C#, how to set or get file attributes, and the FileAttributes Enum. FileAttributes Enum The file Attributes is an Enum that contains attributes fields that can be set or get when dealing with files or directories. Here are the lists of the fields of the FileAttributes... » read more

Startup.cs Class in ASP.NET Core explained

Startup.cs file in .NET Core The primary task of the Startup class is configuring the request pipeline, the series of request delegates that get called serially. This way, the class not only serves to be the starting point of the application but also determines the course the application would eventually take. No wonder all of... » read more

How to get time information of a file in C#

In this article, you will learn how to get time-related information of a file. There are two different methods to achieve this. You can either use static methods of File class or call methods of FileIno class after initiating it. Get time information of a file in C# using the File Class Let’s say you... » read more

Catch Unhandled Exceptions in WinForms Apps using C#

In this article, we will learn how to handle an unhandled exception being thrown in C#. An exception is an error that occurs at runtime, and an unhandled exception occurs when the application fails to handle the exception being thrown properly. Unhandled Exceptions in C# Applications The UnhandledException Event notifies an app whenever an unhandled... » read more

Show/Hide Text Box using JavaScript & jQuery

In this article, you will learn how to show/hide a textbox based on the user’s selection of the drop-down menu. If the user selects yes from the drop-down menu, the text box will appear. Show/Hide a TextBox in Javascript and jQuery HTML <form> <div id="drop-down" name="drop-down"> <label for="travel">Have you visited Europe before? </label> <select name="travel"... » read more

Load Text from File to String variable using C#

In this example, we will show you how to load a text file into a string variable in C#. For this purpose, we are going to use the StreamReader.ReadToEnd method to read from a text file on your local machine, or on a network folder. First, you will need to add the namespace below: using... » read more

Convert HTML table to JSON string in ASP.NET using C# and JavaScript

In this tutorial, I will explain to you how to convert an HTML table to a JSON string using C#. Convert HTML table to JSON in ASP.NET To get started, insert a static table and an ASP button as shown in the code below: <table class="nav-justified" border="1" id="tblEmployees"> <tr> <td><strong>Name</strong></td> <td><strong>Department</strong></td> </tr> <tr> <td>Jeff</td> <td>IT</td>... » read more

Find the Largest Number in an Array using C

Below is a C program with an explanation of how to find the largest number in an array. What is an array? An array is a group of elements of the same data type. It has a consecutive memory location in memory. Each value in the array is called an element. Every element has the... » read more

Introduction to Delegate in C#

Delegate is a reference type variable that can hold the reference of a function. It is like a pointer to a method, in C++ or C. Delegates are implicitly driven from the System.Delegate Class. We can say that it is an object, or reference type variable, which refers to a function, and can hold the... » read more