Server Side Programming Articles

Page 840 of 2109

Difference between namespace in C# and packages in Java

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

Both C# namespaces and Java packages are used to organize code and prevent naming conflicts, but they have different features and implementations. Understanding their differences helps developers work effectively in both languages. Packages in Java Packages in Java are used to prevent naming conflicts, control access, and make searching and locating classes, interfaces, enumerations, and annotations easier. Java packages also provide access control through package-private visibility. Java Package Syntax package package_name; Example // Java equivalent concept in C# using System; namespace Company.Project.Utilities { public class Calculator { ...

Read More

Difference between Static Constructor and Instance Constructor in C#

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

In C#, constructors are special methods used to initialize objects. There are two main types: static constructors and instance constructors. Understanding their differences is crucial for proper class initialization and memory management. Static Constructor A static constructor is declared using the static modifier and is responsible for initializing static members of a class. It executes only once during the application lifetime, before any static members are accessed or any instances are created. Syntax static ClassName() { // initialize static members } Instance Constructor An instance constructor initializes instance ...

Read More

Delegation vs Inheritance in C#

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

In C#, both delegation and inheritance are fundamental concepts that enable code reusability and polymorphism, but they work in fundamentally different ways. Delegation uses composition and method references, while inheritance establishes an "is-a" relationship between classes. Delegation in C# A delegate is a reference type variable that holds references to methods. It enables runtime flexibility by allowing you to change method references dynamically. Delegation follows the composition principle where objects contain references to other objects. Syntax delegate Example using System; public delegate void NotificationHandler(string message); public ...

Read More

Events vs Delegates in C#

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

In C#, both delegates and events provide mechanisms for method invocation, but they serve different purposes and have distinct characteristics. Events are built on top of delegates but provide additional safety and encapsulation features that make them more suitable for notification scenarios. Syntax Following is the syntax for declaring a delegate − public delegate void DelegateName(parameters); Following is the syntax for declaring an event − public delegate void DelegateName(parameters); public event DelegateName EventName; Delegates in C# A delegate is a reference type that holds references to methods with the ...

Read More

Date Class in C#

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

The DateTime class in C# is used to work with dates and times. It represents an instant in time, ranging from 12:00:00 midnight, January 1, 0001 to 11:59:59 P.M., December 31, 9999 A.D. The DateTime class provides various methods and properties to create, manipulate, and format date and time values. Syntax Following is the syntax for creating a DateTime object − DateTime variableName = new DateTime(year, month, day); DateTime variableName = new DateTime(year, month, day, hour, minute, second); To get the current date and time − DateTime current = DateTime.Now; ...

Read More

Counters in C#

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

Counters in C# are performance counters that allow you to monitor your application's performance metrics in real-time. These counters provide valuable insights into system resources, application behavior, and overall performance characteristics. When building applications — whether web, mobile, or desktop — monitoring performance is crucial for identifying bottlenecks, optimizing resource usage, and ensuring smooth operation under various load conditions. Syntax Following is the syntax for creating a performance counter − PerformanceCounter counter = new PerformanceCounter(categoryName, counterName, instanceName); Following is the syntax for reading counter values − float value = counter.NextValue(); ...

Read More

Database Operations in C#

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

Database operations in C# are typically performed using ADO.NET, which provides a set of classes to interact with various databases like SQL Server, MySQL, Oracle, and SQLite. The most common approach involves using connection strings, command objects, and data readers to execute SQL operations. Connection String Syntax A connection string contains the information needed to connect to a database − // SQL Server connection string "Data Source=serverName;Initial Catalog=databaseName;Integrated Security=true;" // SQL Server with username/password "Data Source=serverName;Initial Catalog=databaseName;User ID=username;Password=password;" Establishing Database Connection The SqlConnection class is used to establish a connection to SQL ...

Read More

Decimal Functions in C#

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

The decimal data type in C# provides built-in methods for performing mathematical operations and comparisons on decimal values. These methods are essential for financial calculations and applications requiring high precision arithmetic. Common Decimal Methods Method Description Add(Decimal, Decimal) Adds two specified Decimal values. Ceiling(Decimal) Returns the smallest integral value that is greater than or equal to the specified decimal number. Compare(Decimal, Decimal) Compares two specified Decimal values. CompareTo(Decimal) Compares this instance to a specified Decimal object and returns a comparison of their relative values. ...

Read More

Cohesion in C#

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

Cohesion in C# refers to how closely related and focused the responsibilities within a class or module are. It measures the functional strength and unity of a module's elements. High cohesion means that a class has a single, well-defined purpose with all its methods working together toward that purpose. The greater the cohesion, the better the program design becomes. High cohesion leads to more maintainable, reusable, and understandable code, while low cohesion results in classes that are difficult to maintain and test. Types of Cohesion Cohesion can be categorized from lowest to highest quality − ...

Read More

C# program to replace n-th character from a given index in a string

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

In C#, you can replace a character at a specific index in a string by converting the string to a character array, modifying the desired character, and then creating a new string from the modified array. Syntax Following is the basic syntax for replacing a character at a specific index − char[] charArray = originalString.ToCharArray(); charArray[index] = newCharacter; string newString = new string(charArray); Using ToCharArray() Method The most straightforward approach is to convert the string to a character array, replace the character at the desired index, and construct a new string − ...

Read More
Showing 8391–8400 of 21,090 articles
« Prev 1 838 839 840 841 842 2109 Next »
Advertisements