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
Articles on Trending Technologies
Technical articles with clear explanations and examples
What are punctuators in C#?
Punctuators are special symbols in C# that serve as delimiters to structure, group, and organize code. They are essential for proper syntax and help the compiler understand where statements begin and end, how to group code blocks, and how to separate elements. Common Punctuators in C# The most frequently used punctuators in C# include − { } // Braces - code blocks ( ) // Parentheses - method calls, grouping [ ] // Brackets - arrays, indexers ; // Semicolon - statement terminator , ...
Read MoreLiteral number suffixes in C#
Literal number suffixes in C# are used to explicitly specify the data type of numeric literals. Without suffixes, the compiler infers the type based on the value, but suffixes ensure the literal is treated as a specific numeric type. These suffixes are particularly useful when working with method overloads, preventing ambiguous type conversions, and ensuring the correct data type is used for calculations. Syntax Following is the syntax for using literal number suffixes − dataType variable = numericValue + suffix; The suffix can be either uppercase or lowercase, but uppercase is recommended for ...
Read MoreC# Program to order array elements
C# provides several methods to order array elements. The OrderBy() method sorts elements in ascending order, while ThenBy() is used for secondary sorting criteria when multiple elements have the same primary sort value. Syntax Following is the syntax for ordering array elements using LINQ methods − // Primary ordering IEnumerable result = array.OrderBy(item => item.Property); // Primary and secondary ordering IEnumerable result = array.OrderBy(item => item.Property1) ...
Read MoreBoolean.Equals(Object) Method in C#
The Boolean.Equals(Object) method in C# returns a value indicating whether the current Boolean instance is equal to a specified object. This method compares the Boolean value with another object, returning true only if the object is also a Boolean with the same value. Syntax Following is the syntax − public override bool Equals (object obj); Parameters obj − An object to compare with this Boolean instance. Return Value Returns true if the object is a Boolean instance with the same value; otherwise, false. Using Boolean.Equals() with Different Data Types ...
Read MoreC# Program to convert first character uppercase in a sentence
Converting the first character of each word to uppercase in a sentence is a common text formatting task in C#. This process involves identifying word boundaries and converting the first lowercase letter of each word to its uppercase equivalent. Syntax Following is the basic approach to convert characters from lowercase to uppercase − char uppercaseChar = (char)(lowercaseChar - 'a' + 'A'); To check if a character is a lowercase letter − if (ch >= 'a' && ch = 'a' && val[i] = 'A' && val[i] word.Length > 0 ? ...
Read MoreWhat are sealed modifiers in C#?
The sealed modifier in C# prevents method overriding in derived classes. When applied to an overridden method, it stops further inheritance of that method. The sealed method must be part of a derived class and must override a virtual or abstract method from its base class. Syntax Following is the syntax for declaring a sealed method − public sealed override ReturnType MethodName() { // method implementation } Key Rules for Sealed Methods A sealed method must be an override of a virtual or abstract method. Once ...
Read MoreHow to generate the first 100 Odd Numbers using C#?
To generate the first 100 odd numbers in C#, you can use different approaches. The most straightforward method is to iterate through numbers and check if they are odd using the modulus operator. Syntax Following is the syntax for checking if a number is odd − if (number % 2 != 0) { // number is odd } Following is the syntax for generating odd numbers in a loop − for (int i = 1; i
Read MoreElementAt() method in C#
The ElementAt() method in C# is a LINQ extension method that retrieves an element at a specified index from any collection that implements IEnumerable. It provides a way to access elements by index in collections that don't have built-in indexing support. Syntax Following is the syntax for the ElementAt() method − public static TSource ElementAt(this IEnumerable source, int index) Parameters source − The IEnumerable to return an element from. index − The zero-based index of the element to retrieve. Return Value Returns the element at the specified position in ...
Read MoreC# Program to order array elements in descending order
To order array elements in descending order in C#, you can use various approaches including Array.Sort() with reversal, LINQ's OrderByDescending(), or custom comparison methods. These methods provide flexibility for sorting different data types and applying custom sorting criteria. Syntax Following is the syntax for basic descending sort using Array.Sort() and Array.Reverse() − Array.Sort(arrayName); Array.Reverse(arrayName); Following is the syntax for LINQ OrderByDescending() − var result = array.OrderByDescending(element => element); Using Array.Sort() and Array.Reverse() The simplest approach is to sort the array in ascending order first, then reverse it − ...
Read MoreBoolean.Parse() Method in C#
The Boolean.Parse() method in C# is used to convert the specified string representation of a logical value to its Boolean equivalent. This method converts strings like "true", "false", "TRUE", or "FALSE" to their corresponding boolean values. Syntax Following is the syntax − public static bool Parse(string value); Parameters value − A string containing the value to convert. It can be "true", "false", "True", "False", "TRUE", or "FALSE". Return Value Returns true if the value is equivalent to TrueString, or false if the value is equivalent to FalseString. Using ...
Read More