Programming Articles

Page 865 of 2547

Default constructor in C#

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

A default constructor in C# is a constructor that takes no parameters. When you create an object of a class, the constructor is automatically invoked. The constructor has the same name as the class and is used to initialize the object. If you don't explicitly define any constructor in your class, C# automatically provides a default constructor. However, if you define any parameterized constructor, you must explicitly define the default constructor if you want to use it. Syntax Following is the syntax for declaring a default constructor − public class ClassName { ...

Read More

Major features of C# programming

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

C# is a modern, general-purpose, object-oriented programming language developed by Microsoft. C# is designed for Common Language Infrastructure (CLI), which consists of the executable code and runtime environment that allows the use of various high-level languages on different computer platforms and architectures. C# combines the power of C++ with the simplicity of Visual Basic, making it an ideal choice for developing a wide range of applications from web services to desktop applications. Key Features of C# Major C# Features Core Language ...

Read More

How command line arguments are passed in main method in C#?

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 412 Views

The Main() method is the entry point of a C# application and can accept command line arguments through its args parameter. These arguments allow users to pass data to the program when it starts, making applications more flexible and configurable. Syntax The standard syntax for the Main() method with command line arguments is − static void Main(string[] args) The args parameter is a string array that contains all command line arguments passed to the program − // args[0] = first argument // args[1] = second argument // args.Length = total number of ...

Read More

Lifecycle and States of a Thread in C#

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

Threads are lightweight processes that define a unique flow of control within an application. The lifecycle of a thread starts when an object of the System.Threading.Thread class is created and ends when the thread is terminated or completes execution. Understanding thread states is crucial for effective multithreaded programming in C#. Each thread transitions through various states during its lifetime, and these states determine what operations can be performed on the thread. Thread States Overview The ThreadState enumeration in C# defines the possible states of a thread. Here are the primary states in the lifecycle of a thread ...

Read More

C# Equivalent to Java's Double Brace Initialization?

usharani
usharani
Updated on 17-Mar-2026 372 Views

Java's Double Brace Initialization is a technique that allows creating and initializing collections in a single expression using an anonymous inner class. C# provides equivalent functionality through Collection Initializers and Object Initializers, which offer cleaner and more efficient syntax. Java Double Brace Initialization In Java, double brace initialization uses nested braces where the outer braces create an anonymous class and the inner braces contain an instance initializer − List list = new List() {{ add("One"); add("Two"); add("Three"); add("Four"); }} ...

Read More

How to get complete drive information using C#?

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

Drive information of an Operating System includes key details about storage drives such as drive name, volume label, free space, total size, drive format, and drive type. In C#, you can retrieve this information using the DriveInfo class from the System.IO namespace. Syntax Following is the syntax for creating a DriveInfo object and accessing its properties − DriveInfo driveInfo = new DriveInfo("DriveLetter"); string name = driveInfo.Name; long freeSpace = driveInfo.AvailableFreeSpace; DriveType type = driveInfo.DriveType; DriveInfo Properties Property Description Name Gets the drive name (e.g., "C:") ...

Read More

Print first letter of each word in a string using C# regex

seetha
seetha
Updated on 17-Mar-2026 548 Views

In C#, you can use regular expressions to extract the first letter of each word from a string. This technique uses the Regex.Matches() method with a specific pattern to identify word boundaries and capture the initial characters. Syntax The regular expression pattern to match the first letter of each word is − @"\b[a-zA-Z]" Where − \b − represents a word boundary [a-zA-Z] − matches any single letter (uppercase or lowercase) The Regex.Matches() method syntax − MatchCollection matches = Regex.Matches(inputString, pattern); How It Works ...

Read More

Represent Int32 as a Binary String in C#

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

To represent an Int32 as a binary string in C#, use the Convert.ToString() method with base 2 as the second parameter. This method converts the integer's binary representation into a readable string format. Int32 represents a 32-bit signed integer that can hold values from -2, 147, 483, 648 to 2, 147, 483, 647. Syntax Following is the syntax for converting an integer to binary string − Convert.ToString(value, 2) Parameters value − The integer value to convert to binary representation 2 − The base for binary number system ...

Read More

Static binding vs Dynamic binding in C#

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 3K+ Views

Polymorphism can be static or dynamic. In static polymorphism, the method to be called is determined at compile time. In dynamic polymorphism, the decision is made at runtime based on the actual object type. Static Binding (Compile-Time Polymorphism) Static binding links a function with an object during compile time. It is also called early binding. This is achieved through method overloading and operator overloading. Static Binding Process Source Code Method calls Compiler Resolves calls ...

Read More

How to read inputs as integers in C#?

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 32K+ Views

To read inputs as integers in C#, you need to first read the input as a string using Console.ReadLine() and then convert it to an integer using methods like Convert.ToInt32() or int.Parse(). The process involves two steps: reading the user input as a string and converting it to an integer data type for mathematical operations. Syntax Following is the basic syntax for reading integer input − string input = Console.ReadLine(); int number = Convert.ToInt32(input); You can also use int.Parse() method − int number = int.Parse(Console.ReadLine()); Using Convert.ToInt32() Method ...

Read More
Showing 8641–8650 of 25,466 articles
« Prev 1 863 864 865 866 867 2547 Next »
Advertisements