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
C# Orderby Descending
The orderby descending clause in C# is used with LINQ to sort collections in descending order. It works with both query syntax and method syntax, allowing you to sort objects by any property or field. Syntax Following is the syntax for using orderby descending with LINQ query syntax − var result = from item in collection orderby item.Property descending select item; Following is the syntax for ...
Read MoreWhat are finalizers in C#?
Finalizers in C# are special methods that perform cleanup when an object is being destroyed by the garbage collector. They provide a way to release unmanaged resources before the object is removed from memory. Syntax Following is the syntax for declaring a finalizer − ~ClassName() { // cleanup code here } The finalizer declaration uses a tilde (~) followed by the class name with no parameters or access modifiers. Key Rules Only one finalizer is allowed per class. Finalizers cannot be inherited or overloaded. ...
Read MoreWhat is a non-static class in C#?
A non-static class in C# is a regular class that can be instantiated using the new keyword. Unlike static classes, non-static classes allow you to create multiple objects (instances) and can contain both instance members and static members. Non-static classes are the default type of class in C# and form the foundation of object-oriented programming, enabling encapsulation, inheritance, and polymorphism. Syntax Following is the syntax for declaring a non-static class − public class ClassName { // instance fields // static fields // instance ...
Read MoreImplicit conversion from 16-bit unsigned integer (ushort) to Decimal in C#
ushort represents a 16-bit unsigned integer in C# with a range from 0 to 65, 535. C# allows implicit conversion from ushort to decimal because this conversion is always safe and does not result in data loss. The decimal type can accommodate the entire range of ushort values without precision loss, making implicit conversion possible. Syntax Following is the syntax for implicit conversion from ushort to decimal − ushort ushortValue = value; decimal decimalValue = ushortValue; // implicit conversion How It Works The conversion happens automatically without requiring explicit casting or ...
Read MoreHow to use the Main() method in C#?
The Main() method in C# is the entry point of any C# application. It is a static method that runs when the program starts, without requiring an instance of the class to be created. The Main() method defines what the class does when executed and can instantiate other objects and variables. Syntax Following are the valid signatures for the Main() method − static void Main() static void Main(string[] args) static int Main() static int Main(string[] args) Parameters The Main() method signature includes the following components − static − The method ...
Read MoreWhat are Left Shift and Right Shift Operators (>> and <<) in C#?
The left shift () operators in C# are bitwise operators that shift the bits of a number left or right by a specified number of positions. These operators are commonly used for efficient multiplication and division by powers of 2, as well as for low-level bit manipulation. Syntax Following is the syntax for the left shift operator − result = operand > numberOfPositions; How Left Shift Works The left shift operator (> 3; /* Right shift by 3: 60 / 8 = 7 */ Console.WriteLine("60 >> 3 ...
Read MoreFull Date Long Time ("F") Format Specifier in C#
The Full Date Long Time ("F") format specifier in C# displays a complete date and time representation in a long format. This format specifier uses the current culture's DateTimeFormatInfo.FullDateTimePattern property to determine the exact format string. The "F" specifier provides the most comprehensive date and time display, showing the full day name, complete date, and precise time including seconds. Syntax Following is the syntax for using the "F" format specifier − DateTime.ToString("F") DateTime.ToString("F", CultureInfo) The default custom format string for "F" is − dddd, dd MMMM yyyy HH:mm:ss Using ...
Read MoreHow to use the return statement in C#?
The return statement in C# is used to exit a method and optionally return a value to the caller. When a method contains a return statement, the program control immediately transfers back to the calling method along with the specified return value. Syntax Following is the syntax for using the return statement − return; // For void methods (no value returned) return expression; // For methods that return a value Using Return Statement with Value Types When a method has a return type other than void, it must return a ...
Read MoreMath.Sin() Method in C#
The Math.Sin() method in C# is used to return the sine of a specified angle. The method accepts an angle in radians and returns a double value representing the sine of that angle. Syntax Following is the syntax for the Math.Sin() method − public static double Sin(double val); Parameters val − A double value representing an angle in radians. Return Value The method returns a double value representing the sine of the specified angle. The return value ranges from -1 to 1. For special cases − ...
Read MoreC# program to check if a Substring is present in a Given String
The Contains() method in C# is used to check if a substring is present within a given string. It returns a boolean value − true if the substring is found, and false otherwise. Syntax Following is the syntax for the Contains() method − bool result = string.Contains(substring); Parameters substring − The string to search for within the main string. Return Value The Contains()
Read More