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 is the difference between overriding and hiding in C#?
In C#, method overriding and method hiding (also called shadowing) are two different mechanisms for redefining parent class methods in a derived class. Method overriding uses the override keyword and provides polymorphic behavior, while method hiding uses the new keyword and creates a separate method that shadows the parent method. Syntax Following is the syntax for method overriding using the override keyword − public class BaseClass { public virtual void Method() { } } public class DerivedClass : BaseClass { public override void Method() { } } ...
Read MoreRecommended IDEs for C# on Windows/Linux/Mac OS
Choosing the right IDE is crucial for productive C# development. While Microsoft Visual Studio remains the gold standard on Windows, developers have excellent options across all major operating systems including Windows, Linux, and macOS. Microsoft Visual Studio (Windows) Visual Studio is the flagship IDE for C# development on Windows, offering comprehensive tools for building desktop, web, and mobile applications. Visual Studio Features IntelliSense Code completion Error detection Quick fixes Debugging Breakpoints Variable inspection ...
Read MoreC# Program to display temporary file names
The Path.GetTempPath() method in C# retrieves the path of the system's temporary folder where temporary files are stored. This method is useful when your application needs to create temporary files or work with the system's designated temporary directory. Syntax Following is the syntax for using Path.GetTempPath() method − string tempPath = Path.GetTempPath(); Return Value The method returns a string representing the path to the system's temporary directory. On Windows, this is typically the path specified by the TEMP or TMP environment variables. On Unix-like systems, it's usually /tmp/. Using GetTempPath() to Display ...
Read MoreRepresent Int64 as a String in C#
The Int64 data type in C# represents a 64-bit signed integer that can hold values from -9, 223, 372, 036, 854, 775, 808 to 9, 223, 372, 036, 854, 775, 807. Converting an Int64 to a string is a common operation that can be accomplished using several methods, with ToString() being the most straightforward approach. Syntax The basic syntax for converting an Int64 to string using ToString() method − long variable = value; string result = variable.ToString(); You can also use format specifiers with ToString() − string result = variable.ToString("format"); ...
Read MoreDateTime.ToLongDateString() Method in C#
The DateTime.ToLongDateString() method in C# converts a DateTime object to its equivalent long date string representation. This method returns a human-readable date format that includes the day of the week, month name, day, and year, formatted according to the current culture settings. Syntax Following is the syntax − public string ToLongDateString(); Return Value This method returns a string that represents the long date format of the DateTime object. The format follows the current culture's long date pattern, typically in the form "Day, Month Date, Year". Using ToLongDateString() with Specific DateTime The ...
Read MoreRepresent Int64 as a Hexadecimal String in C#
To represent Int64 as a hexadecimal string in C#, use the Convert.ToString() method and set the base as 16 for hexadecimal conversion. Int64 represents a 64-bit signed integer that can hold values from -9, 223, 372, 036, 854, 775, 808 to 9, 223, 372, 036, 854, 775, 807. Syntax Following is the syntax for converting Int64 to hexadecimal string − Convert.ToString(longValue, 16) You can also use the ToString() method with format specifiers − longValue.ToString("X") // Uppercase hex longValue.ToString("x") // Lowercase hex Using Convert.ToString() Method The ...
Read MoreDateTime.ToLongTimeString() Method in C#
The DateTime.ToLongTimeString() method in C# is used to convert the value of the current DateTime object to its equivalent long time string representation. This method formats the time portion of a DateTime object according to the current culture's long time format pattern. Syntax Following is the syntax − public string ToLongTimeString(); Return Value Returns a string that contains the long time string representation of the current DateTime object, formatted according to the current culture's long time pattern. Using ToLongTimeString() with Current DateTime The method uses the current system culture to determine ...
Read MoreThe "0" custom format specifier in C#
The "0" custom format specifier in C# is a zero placeholder that ensures a digit appears in each specified position. If the value being formatted has a digit in that position, it displays the digit; otherwise, it displays a zero. This format specifier is particularly useful for creating fixed-width numeric displays, padding numbers with leading zeros, or ensuring decimal places are always shown. Syntax Following is the syntax for using the "0" custom format specifier − number.ToString("000") // For integers with leading zeros number.ToString("0.00") // For decimals with ...
Read MoreC# program to count upper and lower case characters in a given string
To count uppercase and lowercase characters in a string, we can iterate through each character and check if it falls within specific ASCII ranges. For uppercase letters, we check if the character is between 'A' and 'Z', while for lowercase letters, we check if it's between 'a' and 'z'. Syntax Following is the syntax for checking uppercase characters − if (myStr[i] >= 'A' && myStr[i] = 'a' && myStr[i] = 'a' && myStr[i] = 'A' && myStr[i]
Read MoreAbort in C#
The Thread.Abort() method in C# is used to forcibly terminate a thread by throwing a ThreadAbortException. This method was commonly used in older versions of .NET Framework but is now deprecated and not supported in .NET Core and .NET 5+. Important Note: Thread.Abort() is considered unsafe and unreliable. Modern C# applications should use cooperative cancellation with CancellationToken instead. Syntax Following is the syntax for using Thread.Abort() − thread.Abort(); The method throws a ThreadAbortException that can be caught, but the thread will still terminate − try { // thread ...
Read More