Different date conversion from string to date in C#

In the article, we will learn about various date conversion method that converts date type String to data type date. To better understand this tutorial, you should be knowledgeable in  following C# programming topic: C# if statement Sting to Date conversion is one of the most used transformations in software development. For some reasons, software developers... » read more

Introduction to Dictionary Initializer in C#

Dictionary Initializer got introduced in Visual Studio 2015, .NET 4.6 and C#6.0. With its use, we were able to map indexer during the initialization of the dictionary object. Let us now look in the fact of how this could be used complete elaboration. To better understand this tutorial, you should know following C# programming topic:... » read more

Introduction to iterator in C# and VB.NET

In this article, I will discuss the type of iterators that are supported by C# and VB.NET. .NET Framework usually supports two different kinds of the iterator: External and Internal External iterator: It is the statement where we should specify every single step for completing the task. You can consider the below code: C# List<string>... » read more

Creating Repository pattern in ASP.net MVC

In this article, I will help you to understand how to create a Repository Pattern that is mainly used for large enterprise application. The Repository pattern divides the application’s UI, components of data access and business logic into several layers which are easy to test and maintain. A Employees application will be created which will... » read more

Insert Update Delete example in C# and VB.NET Using ExecuteNonQuery method

ExecuteNonQuery is a method from the SQlCommand Class in the System.Data.SqlClient namespace. It executes a T-SQL query and returns the number of rows affected. Below are examples of how to run an Insert, Delete, and Update statements using the ExecuteNonQuery method in both C# and VB.NET. Required namespaces C# using System.Data; using System.Data.SqlClient; VB.NET Imports... » read more

Bind chart control using C# and Linq

Charts are popular and can help to visualize the data in a WinForm application. This tutorial will focus on how to create and bind charts using C# and Linq. To better understand this tutorial, you should know the following C# programming area: C# ‘for’ Loop Here are the steps to proceed with the tutorial: 1- Create... » read more

Populate DataTable using DataReader in C#

Below is an example of how to populate a DataTable using a DataReader in C#. First, let’s create the database table as showing below: Design View SQL CREATE TABLE [dbo].[ProgrammingLanguage] ( [ID] INT NOT NULL, [LanguageName] NVARCHAR (50) NULL, PRIMARY KEY CLUSTERED ([ID] ASC) ); Then add a few records to that table: Now create... » read more

Bind an ADO.NET DataTable to a ListBox using C#

This tutorial will teach you how to bind a ListBox in C#. First, open Visual Studio, create a C# windows application project and then add a ListBox to the main form of that application. Create the table in Microsoft SQL Server as shown below. SQL Code USE [TutorialsPanel] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER... » read more

Get local IP address list using C#

Use the Static method Dns.GetHostAddresses to get a list of computer IP Addresses. First, you need to to get the Computer name. Then pass it as a parameter to the Dns.GetHostAddresses method. Required Namespace: System.Net C# String ComputerName= Dns.GetHostName(); IPAddresses[] localIPs = Dns.GetHostAddresses(ComputerName);

Socket connect and data send using C#

This tutorial will explain how to connect to a host machine, and then send data via TCP Socket. First, we need to add the namespaces: using System.Net; using System.Net.Sockets; And the function: public static void SendData(string data, Int32 port, string ips) { IPAddress host = IPAddress.Parse(ips);// IPEndPoint ipendpoint = new IPEndPoint(host, port); // assign host... » read more

Function Returns DataTable Using C#

Below is a function that returns a DataTable using in C#. DataTables are derived from the namespace System.Data. We will also use a DataAdapter in this example. The DataAdapter Fills the DataTable from a SQL Database based on a SQL Query which is defined in a SQLCommand. Database C# protected DataTable GetAllRecords() { SqlConnection sqlconn... » read more