Server Side Programming Articles

Page 766 of 2109

What is the maximum possible value of an integer in C# ?

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

The maximum possible value of a 32-bit signed integer (int) in C# is 2, 147, 483, 647. This value is also available through the constant int.MaxValue. However, C# provides several integer types with different ranges and maximum values. Integer Types and Their Maximum Values C# offers multiple integer data types, each with different storage sizes and value ranges − Type Size Range Maximum Value sbyte 8-bit signed -128 to 127 127 byte 8-bit unsigned 0 to 255 255 short 16-bit signed -32, 768 to 32, 767 ...

Read More

How to define custom methods in C#?

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

To define a custom method in C#, you create a reusable block of code that performs a specific task. Methods help organize your code, make it more readable, and avoid repetition by allowing you to call the same functionality multiple times. Syntax Following is the syntax for defining a custom method in C# − (Parameter List) { Method Body } Method Components The following are the various elements of a method − Access Specifier − This determines the visibility of a method from other classes. ...

Read More

Why we do not have global variables in C#?

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

C# does not have global variables like those found in C or C++. Instead, C# follows an object-oriented paradigm where all data and methods must be contained within classes or structures. The global namespace alias (global::) is used to resolve naming conflicts between namespaces, not to access global variables. Why C# Doesn't Have Global Variables C# was designed with several principles that eliminate the need for global variables − Type Safety: Global variables can lead to unpredictable behavior and make debugging difficult. Object-Oriented Design: Everything must belong to a class or struct, promoting ...

Read More

How to define multiline String Literal in C#?

George John
George John
Updated on 17-Mar-2026 1K+ Views

A multiline string literal in C# allows you to define strings that span multiple lines while preserving the line breaks and formatting. This is achieved using the @ symbol prefix, which creates a verbatim string literal. Syntax Following is the syntax for defining a multiline string literal − string variableName = @"Line 1 Line 2 Line 3"; The @ symbol tells the compiler to treat the string literally, preserving all whitespace, line breaks, and special characters without requiring escape sequences. Using Verbatim String Literals Let's say you want to create a string ...

Read More

How to call a method of a class in C#

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

To call a method of a class in C#, you need to create an instance of the class first, then use the dot notation to access its methods. The general syntax is objectName.MethodName(parameters). Syntax Following is the syntax for calling an instance method − ClassName objectName = new ClassName(); returnType result = objectName.MethodName(parameters); For static methods, you call them directly on the class without creating an instance − returnType result = ClassName.StaticMethodName(parameters); Using Instance Methods Instance methods require an object of the class to be called. Here's how you ...

Read More

How to capture divide by zero exception in C#?

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

The System.DivideByZeroException is a class that handles errors generated from dividing a number by zero. This exception occurs when you attempt to divide an integer or decimal value by zero during arithmetic operations. In C#, you can capture and handle this exception using try-catch blocks to prevent your application from crashing and provide meaningful error messages to users. Syntax Following is the syntax for handling divide by zero exception − try { result = dividend / divisor; } catch (DivideByZeroException e) { // Handle the exception ...

Read More

What are contextual keywords in C#?

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

In C#, contextual keywords are special identifiers that have reserved meaning only in specific contexts. Unlike regular keywords, they can still be used as variable names or identifiers when not in their special context. Common examples include get and set in properties, where in LINQ queries, and partial in class definitions. Contextual keywords provide flexibility by allowing the same word to serve as both a keyword and an identifier depending on the context in which it appears. Syntax Contextual keywords are used within their specific contexts. Here are some common patterns − // Property accessors ...

Read More

What are dynamic arrays in C#?

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

Dynamic arrays are growable arrays that can resize themselves during runtime, providing a significant advantage over static arrays which have a fixed size. In C#, you can create dynamic arrays using collections like ArrayList and the more modern List. These dynamic collections allow automatic memory allocation, resizing, adding, searching, and sorting items efficiently. The ArrayList stores objects of any type, while List is type-safe and performs better. Syntax Following is the syntax for creating an ArrayList − ArrayList arrayList = new ArrayList(); arrayList.Add(item); Following is the syntax for creating a generic List − ...

Read More

What are the differences between constructors and destructors in C#?

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

A constructor is a special member function that initializes objects when they are created, while a destructor is called when an object goes out of scope or is garbage collected. Understanding the differences between these two fundamental concepts is essential for proper object lifecycle management in C#. Constructors A constructor is a special method that is automatically called when an object is created. It has the same name as the class and no return type. Syntax class ClassName { public ClassName() { // constructor code ...

Read More

What are the differences between ref and out parameters in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 768 Views

The ref and out parameters in C# are both used to pass arguments by reference, but they have distinct behaviors and use cases. Both allow methods to modify the original variable, but they differ in initialization requirements and intended purposes. Syntax Following is the syntax for declaring ref parameters − public void MethodName(ref int parameter) { // parameter can be read and modified } Following is the syntax for declaring out parameters − public void MethodName(out int parameter) { // parameter must be assigned ...

Read More
Showing 7651–7660 of 21,090 articles
« Prev 1 764 765 766 767 768 2109 Next »
Advertisements