Articles on Trending Technologies

Technical articles with clear explanations and examples

C# Orderby Descending

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 442 Views

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 More

What are finalizers in C#?

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 1K+ Views

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 More

What is a non-static class in C#?

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 1K+ Views

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 More

Implicit conversion from 16-bit unsigned integer (ushort) to Decimal in C#

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 562 Views

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 More

How to use the Main() method in C#?

George John
George John
Updated on 17-Mar-2026 859 Views

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 More

What are Left Shift and Right Shift Operators (>> and <<) in C#?

George John
George John
Updated on 17-Mar-2026 1K+ Views

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 More

Full Date Long Time ("F") Format Specifier in C#

Samual Sam
Samual Sam
Updated on 17-Mar-2026 264 Views

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 More

How to use the return statement in C#?

Samual Sam
Samual Sam
Updated on 17-Mar-2026 684 Views

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 More

Math.Sin() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 829 Views

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 More

C# program to check if a Substring is present in a Given String

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 724 Views

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
Showing 10881–10890 of 61,297 articles
Advertisements