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 756 of 2109
How to create 5-Tuple or quintuple in C#?
A 5-tuple or quintuple in C# is represented by the Tuple class, which is a data structure that holds exactly five elements of potentially different types. Each element can be accessed through its corresponding Item property. Syntax Following is the syntax for creating a 5-tuple using the constructor − Tuple tuple = new Tuple(item1, item2, item3, item4, item5); You can also use the Tuple.Create() method for shorter syntax − var tuple = Tuple.Create(item1, item2, item3, item4, item5); Properties A 5-tuple has five read-only properties to access its elements − ...
Read MoreBinary search in C#
The binary search algorithm works on the divide and conquer principle as it keeps dividing the array in half before searching. To search for an element in an array using binary search, the array must be sorted. In the sorted array, we find the middle element and compare it with the element that has to be searched, and based on the comparison, we either search in the left sub-array, right sub-array, or return the middle element. In this article, we are given a sorted array of integers, and our task is to search for the given target element ...
Read MoreWhat is the Count property of BitArray class in C#?
The Count property of the BitArray class in C# returns the total number of elements (bits) in the BitArray. This is a read-only property that gives you the size of the BitArray, which is determined when the BitArray is created. Syntax Following is the syntax for accessing the Count property − int count = bitArray.Count; Return Value The Count property returns an int value representing the number of bits in the BitArray. Using Count Property with BitArray Let us first create a BitArray and then use the Count property to get ...
Read MoreHow to get int value from enum in C#?
In C#, an enum (enumeration) is a value type that represents a group of named constants. By default, each enum value has an underlying integer value starting from 0. You can extract the integer value from an enum using type casting. Syntax Following is the syntax for casting an enum to int − int value = (int)EnumName.EnumValue; Following is the syntax for declaring an enum − public enum EnumName { Value1, Value2, Value3 } Using Default Integer Values By default, enum values are assigned integer values starting from 0 ...
Read MoreHow to write single-line comments in C#?
Single-line comments in C# are created using two forward slashes (//). Everything after the // on that line is treated as a comment and is ignored by the compiler. These comments are useful for explaining code, adding notes, or temporarily disabling a line of code. Syntax Following is the syntax for single-line comments in C# − // This is a single-line comment int variable = 10; // Comment at the end of a line Using Single-Line Comments for Code Documentation Example using System; namespace Demo { class ...
Read MoreMedium-Earth Orbit Satellites
This article appears to be about satellite orbits, not C# programming. As a C# tutorial enhancement specialist, I can only improve C# programming articles for TutorialsPoint.com. Please provide a C# programming article that needs improvement, such as topics related to: C# language features (classes, methods, properties, etc.) .NET Framework concepts Object-oriented programming in C# C# syntax and programming constructs C# libraries and APIs I'll be happy to enhance any C# programming tutorial following the TutorialsPoint standards with proper code formatting, examples, and structure.
Read MoreC# program to iterate over a string array with for loop
A string array in C# can be iterated using a for loop to access each element by its index. The loop runs from index 0 to the length of the array minus one, allowing you to process each string element sequentially. Syntax Following is the syntax for iterating over a string array with a for loop − for (int i = 0; i < arrayName.Length; i++) { // Access element: arrayName[i] } The Length property returns the total number of elements in the array, and the loop variable i serves ...
Read MoreC# program to display the previous day
To display the previous day in C#, use the AddDays() method with a value of -1. This method allows you to add or subtract days from a DateTime object. Syntax Following is the syntax for getting the current date − DateTime.Today Following is the syntax for getting the previous day using AddDays() − DateTime.Today.AddDays(-1) Using DateTime.Today.AddDays(-1) The DateTime.Today property returns the current date with the time set to midnight. The AddDays(-1) method subtracts one day from this date − using System; public class Demo { ...
Read MoreC# Program to find the largest element from an array
Finding the largest element in an array is a common programming task in C#. There are multiple approaches to achieve this, ranging from using built-in LINQ methods to implementing custom logic with loops. Using LINQ Max() Method The simplest approach is to use the Max() method from the System.Linq namespace − using System; using System.Linq; class Demo { static void Main() { int[] arr = { 20, 50, -35, 25, 60 }; int largest = ...
Read MoreWhat is the operator that concatenates two or more string objects in C#?
The + operator is used to concatenate two or more string objects in C#. This operator provides a simple and intuitive way to combine strings, making it one of the most commonly used string operations in C# programming. Syntax Following is the basic syntax for string concatenation using the + operator − string result = string1 + string2; string result = string1 + string2 + string3; Using + Operator for String Concatenation Example 1: Basic String Concatenation using System; class Program { static void Main() { ...
Read More