Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Server Side Programming Articles
Page 687 of 2109
C# Program to Generate Marksheet of Student
A marksheet generation program is a practical application that calculates a student's total marks, percentage, and grade based on subject scores. This C# program demonstrates how to create a simple marksheet system using basic input/output operations, arithmetic calculations, and conditional logic. Algorithm The marksheet generation follows these steps − Step 1 − Declare variables for student roll number, name, subject marks, total marks, and percentage. Step 2 − Accept input for student details and marks in each subject. Step 3 − Calculate total marks by summing all subject marks. Step 4 − Calculate percentage ...
Read MoreC# Program to Get and Print the Command Line Arguments Using Environment Class
The Environment class in C# provides access to current environment and platform information, including command line arguments. The Environment.CommandLine property retrieves the complete command line that started the current process, including the executable name and all arguments. Environment Class Overview The Environment class offers various properties and methods to access system information − Environment.CommandLine − Gets the complete command line Environment.GetCommandLineArgs() − Gets arguments as a string array Environment.CurrentDirectory − Gets current working directory Environment.OSVersion − Gets operating system version Environment.MachineName − Gets computer name Environment.ProcessorCount − Gets processor count ...
Read MoreC# Program to Sort a List of Employees Based on Salary using LINQ
In many software development projects, there comes a point where it becomes necessary to sort a list of objects based on one or more properties of the objects. In C#, the LINQ (Language Integrated Query) library provides a powerful and easy-to-use way to sort lists of objects based on one or more criteria. In this tutorial, we will demonstrate how to sort a list of Employee objects based on their salary using LINQ. Syntax Following is the syntax for sorting a list using LINQ OrderBy methods − // Sort in ascending order var sortedList = list.OrderBy(item ...
Read MoreC# Program to Trap Events From File
Welcome to our comprehensive guide on creating a C# program to trap events from a file. File event monitoring allows your application to respond to file system changes in real-time, making it useful for scenarios like log monitoring, file synchronization, and automated backup systems. Understanding FileSystemWatcher In C#, the FileSystemWatcher class monitors file system events and triggers notifications when files or directories are created, modified, deleted, or renamed. This class provides a powerful mechanism for building responsive applications that react to file system changes. FileSystemWatcher offers several key events − Created − Occurs when a ...
Read MoreCheck if the given ranges are equal or not in C#
As programmers, we often encounter situations where we need to compare two ranges in a programming language like C#. Whether we're working on complex algorithms or simple programs, checking if two ranges are equal can be a critical task. This article will discuss the process and methods to compare two given ranges in C#, providing a straightforward solution to this common problem. Understanding Ranges in C# Before we proceed to the solution, it's vital to have a firm understanding of what ranges are in the C# programming language. Introduced in C# 8.0, ranges are a new feature that ...
Read MoreChecking the Given Indexes are Equal or not in C#
Indexes are a vital part of working with arrays and other data structures in C#. They help us navigate and manipulate data effectively. This article will guide you on how to check whether given indexes in a data structure are equal or not in C#. Understanding Indexes in C# In C#, an index represents a position in an array or collection. The index of the first element is 0, and it increases by one for each subsequent element. This is called zero-based indexing. Array Index Positions ...
Read MoreConsole.TreatControlCAsInput Property in C# with Examples
The Console.TreatControlCAsInput property in C# is a Boolean property that determines whether the Ctrl+C key combination is treated as ordinary input or as an interruption signal handled by the operating system. By default, pressing Ctrl+C terminates a console application. However, setting this property to true allows the application to capture Ctrl+C as regular input, preventing automatic termination. Syntax Following is the syntax for setting and getting the Console.TreatControlCAsInput property − // Setting the property Console.TreatControlCAsInput = true; // or false // Getting the property value bool treatAsInput = Console.TreatControlCAsInput; Default Behavior ...
Read MoreConverting a String to its Equivalent Byte Array in C#
String manipulation is a common task in C# programming. In certain cases, you might need to convert a string into its equivalent byte array, such as when dealing with encryption, file I/O, or network communication. This article will walk you through the process of converting a string to a byte array in C#, illustrating the power and flexibility of C# in handling various data types. Understanding Strings and Byte Arrays in C# Before diving into the conversion process, let's understand what strings and byte arrays are in C#. In C#, a string is a sequence of characters, while ...
Read MoreDelegates vs Interfaces in C#
Delegates and interfaces are both powerful constructs in C# that allow for flexible and extensible code. While they serve different purposes, they can sometimes be used to achieve similar ends, leading to confusion about when to use one over the other. This article will elucidate the differences and similarities between delegates and interfaces, and provide guidelines for their use. Syntax Following is the syntax for declaring a delegate − public delegate returnType DelegateName(parameters); Following is the syntax for declaring an interface − public interface IInterfaceName { returnType MethodName(parameters); } ...
Read MoreHow to Add Items to Hashtable Collection in C#
A Hashtable collection in C# stores key-value pairs using a hash-based mechanism. Each key-value pair is organized based on the hash code of the key, which is calculated using a hash function. Unlike modern generic collections, hashtables can store objects of different data types but exhibit lower performance due to boxing and unboxing operations. In this article, we will explore how to add items to a hashtable collection using various methods available in the Hashtable class. Syntax The primary method for adding items to a hashtable is the Add() method − public virtual void Add(object ...
Read More