Programming Articles

Page 90 of 2547

How to clear screen using C#?

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 12K+ Views

The Console.Clear() method in C# is used to clear the console screen and its buffer. When this method is called, the cursor automatically moves to the top-left corner of the console window, effectively giving you a clean slate to work with. Syntax Following is the syntax for the Console.Clear() method − Console.Clear(); How It Works The Console.Clear() method performs the following actions − Clears all text and content from the console window Resets the cursor position to (0, 0) — the top-left corner Preserves the current ...

Read More

C# Console.WindowLeft Property

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 287 Views

The Console.WindowLeft property in C# gets or sets the leftmost position of the console window area relative to the screen buffer. This property is useful when you need to control or retrieve the horizontal position of the console window within the buffer area. Syntax Following is the syntax to get the left position of the console window − int position = Console.WindowLeft; Following is the syntax to set the left position of the console window − Console.WindowLeft = value; Return Value The property returns an int value representing the ...

Read More

Exception Propagation in C#

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

Exception propagation in C# refers to the process of how exceptions move up through the call stack when they are not handled by the current method or try-catch block. When an exception occurs, the runtime searches for an appropriate exception handler, and if none is found, the exception propagates to the calling method. How Exception Propagation Works When an exception occurs in a try block, the runtime checks the corresponding catch blocks to see if they can handle the exception. If no matching catch block is found, the exception propagates to a higher-level try block or to the ...

Read More

Int32.GetTypeCode Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 173 Views

The Int32.GetTypeCode() method in C# returns the TypeCode enumeration value for the Int32 data type. This method is inherited from the IConvertible interface and is useful for type identification and runtime type checking operations. Syntax Following is the syntax − public TypeCode GetTypeCode(); Return Value This method returns TypeCode.Int32 for all int values, regardless of their actual numeric value. Using GetTypeCode() for Type Identification Example Let us see an example to implement the Int32.GetTypeCode() method − using System; public class Demo { public ...

Read More

Int16.CompareTo() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 6K+ Views

The Int16.CompareTo() method in C# is used to compare a 16-bit signed integer (short) with another value and returns an integer that indicates their relative order. This method is essential for sorting operations and determining the relationship between two Int16 values. Syntax The Int16.CompareTo() method has two overloads − public int CompareTo(short value); public int CompareTo(object value); Parameters value − A 16-bit signed integer or an object to compare with the current instance. Return Value The method returns an integer with the following meaning − ...

Read More

C# Program to replace a character with asterisks in a sentence

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

The Replace() method in C# is used to replace all occurrences of a specified character or string with another character or string. This method is particularly useful when you need to replace special characters like asterisks with other characters in a sentence. Syntax Following is the syntax for replacing a character using the Replace() method − string newString = originalString.Replace(oldChar, newChar); For replacing a string with another string − string newString = originalString.Replace(oldString, newString); Parameters oldChar/oldString: The character or string to be replaced newChar/newString: The character or string to replace with Return Value The Replace()

Read More

Append to StringBuilder in C#

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

The Append() method in C# is used to add content to a StringBuilder object. Unlike strings, which are immutable, StringBuilder allows efficient concatenation of text without creating new string objects in memory. StringBuilder is particularly useful when you need to perform multiple string concatenations, as it provides better performance than using the + operator repeatedly. Syntax Following is the syntax for creating a StringBuilder and using the Append() method − StringBuilder sb = new StringBuilder(); sb.Append(value); The Append() method can accept various data types including string, char, int, double, and others. It returns ...

Read More

C# difference in milliseconds between two DateTime

Samual Sam
Samual Sam
Updated on 17-Mar-2026 8K+ Views

In C# programming, you often need to calculate the time difference between two DateTime objects. The most efficient way to get the difference in milliseconds is by using the TimeSpan structure and its TotalMilliseconds property. Syntax Following is the syntax for calculating milliseconds difference between two DateTime objects − DateTime date1 = new DateTime(year, month, day, hour, minute, second); DateTime date2 = new DateTime(year, month, day, hour, minute, second); TimeSpan difference = date2 - date1; double milliseconds = difference.TotalMilliseconds; Using TimeSpan to Calculate Milliseconds Difference When you subtract one DateTime from another, the ...

Read More

Dictionary Methods in C#

Samual Sam
Samual Sam
Updated on 17-Mar-2026 5K+ Views

Dictionary is a collection of keys and values in C#. Dictionary is included in the System.Collections.Generic namespace and provides methods to add, remove, and search for key-value pairs efficiently. Common Dictionary Methods Method Description Add(TKey, TValue) Adds a key-value pair to the Dictionary Remove(TKey) Removes the element with the specified key Clear() Removes all keys and values from the Dictionary ContainsKey(TKey) Checks whether the specified key exists ContainsValue(TValue) Checks whether the specified value exists TryGetValue(TKey, out TValue) Safely retrieves a value ...

Read More

UInt64.CompareTo() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 242 Views

The UInt64.CompareTo() method in C# is used to compare the current instance to a specified object or UInt64 and returns an indication of their relative values. This method is essential for sorting operations and numerical comparisons with 64-bit unsigned integers. Syntax The UInt64.CompareTo() method has two overloads − public int CompareTo(object val); public int CompareTo(ulong val); Parameters val − An object or unsigned 64-bit integer to compare with the current instance. Return Value The method returns an integer that indicates the relative position of the current instance ...

Read More
Showing 891–900 of 25,467 articles
« Prev 1 88 89 90 91 92 2547 Next »
Advertisements