Ankith Reddy

Ankith Reddy

730 Articles Published

Articles by Ankith Reddy

Page 6 of 73

Naming Conventions in C#

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

Naming conventions in C# help maintain code readability and consistency across projects. Following standardized naming patterns makes your code more professional and easier to understand for other developers. Class Naming Conventions A class definition starts with the class keyword followed by the class name, enclosed by curly braces. The following conventions apply to class names. Pascal Casing Class names should use PascalCasing, where the first letter of each word is capitalized − public class EmployeeDetails { } public class BankAccount { } public class CustomerOrderHistory { } Noun or Noun Phrases ...

Read More

C# program to display the next day

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

To display the next day in C#, use the AddDays() method with a value of 1. The AddDays() method adds or subtracts days from a DateTime object and returns a new DateTime representing the modified date. Syntax Following is the syntax for using AddDays() method − DateTime.AddDays(double value) Parameters value − A number of whole and fractional days. Use positive values for future dates and negative values for past dates. Return Value The method returns a new DateTime object that represents the date and time with the ...

Read More

Remove an item from a Hashtable in C#

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

The Hashtable class in C# provides the Remove() method to delete key-value pairs. The method takes the key as a parameter and removes the corresponding entry from the hashtable if it exists. Syntax Following is the syntax for removing an item from a Hashtable − hashtable.Remove(key); Parameters key − The key of the element to remove from the hashtable. Return Value The Remove()

Read More

What are file operations in C#?

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

File operations in C# allow you to work with files and directories on the file system. These operations include creating, opening, reading, writing, appending, and deleting files. The System.IO namespace provides comprehensive classes and methods for file handling. The FileStream class is the primary class for file operations in C#. It provides low-level access to files and derives from the abstract Stream class. This class enables reading from, writing to, and closing files efficiently. Syntax To create a FileStream object, use the following syntax − FileStream fileStream = new FileStream(fileName, FileMode, FileAccess, FileShare); ...

Read More

C# TicksPer constants

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

The TicksPer constants in C# are predefined values in the TimeSpan class that represent the number of ticks for different time units. A tick is the smallest unit of time measurement in .NET, where one tick equals 100 nanoseconds. These constants help convert between ticks and common time measurements. Available TicksPer Constants The TimeSpan class provides the following TicksPer constants − TicksPerDay − Number of ticks in one day TicksPerHour − Number of ticks in one hour TicksPerMinute − Number of ticks in one minute TicksPerSecond − Number of ticks in one second TicksPerMillisecond − Number ...

Read More

How to use StringBuilder in C#?

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

The StringBuilder class in C# is designed for efficient string manipulation when you need to perform multiple operations like appending, inserting, or replacing characters. Unlike regular strings, which are immutable and create new objects for every modification, StringBuilder maintains a mutable buffer that can be expanded without creating new objects in memory. Syntax Following is the syntax to initialize a StringBuilder − StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder(string value); StringBuilder sb = new StringBuilder(int capacity); StringBuilder sb = new StringBuilder(string value, int capacity); Key Advantages of StringBuilder Mutable ...

Read More

C# Program to set the timer to zero

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

The Stopwatch class in C# provides precise timing capabilities. To set the timer to zero, you can use the Restart() method, which stops the current timer and immediately starts it again from zero. Syntax Following is the syntax to create and start a Stopwatch − Stopwatch stopwatch = Stopwatch.StartNew(); Following is the syntax to restart the timer and set it to zero − stopwatch.Restart(); Using Restart() Method The Restart() method combines two operations: it stops the current timer and immediately starts a new timing session from zero. This is ...

Read More

What are nested namespaces in C#?

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

A nested namespace in C# is a namespace declared inside another namespace. This hierarchical structure helps organize code logically by grouping related classes and functionalities under appropriate namespace levels. Nested namespaces provide better code organization, prevent naming conflicts, and create a logical hierarchy that reflects the structure of your application. Syntax Following is the syntax for declaring nested namespaces − namespace OuterNamespace { namespace InnerNamespace { public class MyClass { // ...

Read More

ContainsKey in C#

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

The ContainsKey method in C# is a Dictionary method that checks whether a specified key exists in the dictionary. It returns a boolean value − true if the key is found, false otherwise. This method is essential for safe dictionary operations to avoid exceptions when accessing non-existent keys. Syntax Following is the syntax for the ContainsKey method − public bool ContainsKey(TKey key) Parameters key − The key to locate in the dictionary. This parameter cannot be null for reference types. Return Value Returns true if the dictionary ...

Read More

How to use the directory class in C#?

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

The Directory class in C# is used to manipulate the directory structure. It provides static methods to create, move, delete, and query directories without needing to create an instance of the class. The Directory class is part of the System.IO namespace and offers essential functionality for working with file system directories programmatically. Syntax Following is the basic syntax for using Directory class methods − Directory.MethodName(path); Directory.MethodName(path, parameters); Common Directory Class Methods Method Description CreateDirectory(String) Creates all directories and subdirectories in the specified path ...

Read More
Showing 51–60 of 730 articles
« Prev 1 4 5 6 7 8 73 Next »
Advertisements