Csharp Articles

Page 92 of 196

What is the difference between a float, double and a decimal in C#?

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

Float, double, and decimal are all value types in C# that represent numeric data with fractional parts. Each type differs in precision, memory size, and intended use cases. Understanding these differences is crucial for choosing the appropriate type for your specific needs. Syntax Following is the syntax for declaring float, double, and decimal variables − float floatValue = 3.14f; // 'f' suffix required double doubleValue = 3.14; // default for literals decimal decimalValue = 3.14m; // 'm' suffix required Float Value Type Float ...

Read More

What are static members of a C# Class?

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

Static members in C# belong to the class itself rather than to any specific instance of the class. When you declare a member as static, only one copy exists regardless of how many objects are created from the class. Static members are accessed using the class name directly, without creating an instance. They are commonly used for utility functions, constants, and shared data that should be consistent across all instances of a class. Syntax Following is the syntax for declaring static members − public static dataType memberName; public static returnType MethodName() { ...

Read More

What is the default access for a class in C#?

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

In C#, when no access modifier is specified for a class, the default access level is internal. An internal class can be accessed from any code within the same assembly but is not accessible from other assemblies. This means that classes declared without an explicit access modifier are visible throughout the current project or assembly, but remain hidden from external assemblies that might reference your code. Syntax Following is the syntax for declaring a class with different access levels − // Default access (internal) class MyClass { } // Explicitly internal internal class MyClass ...

Read More

What is run time polymorphism in C#?

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

Runtime polymorphism in C# allows the same method call to behave differently depending on the actual type of object at runtime. This is achieved through method overriding, also known as dynamic binding or late binding. It is implemented using abstract classes and virtual functions. In runtime polymorphism, the method to be called is determined at runtime based on the object's actual type, not the reference type declared at compile time. Runtime Polymorphism Flow Base Class Circle Rectangle ...

Read More

What is the difference between a class and an object in C#?

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

When you define a class, you define a blueprint or template for a data type. The object is an instance of that class − a concrete implementation created from the blueprint. A class defines the structure and behavior, while objects are the actual entities that hold data and perform actions. The methods and variables that constitute a class are called members of the class. To access class members, you use the dot (.) operator after the object name. The dot operator links the name of an object with the name of a member. Class vs Object ...

Read More

What are the difference between Composition and Aggregation in C#?

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

Composition and Aggregation are two important types of associations in C# that represent different levels of dependency between classes. Understanding these relationships helps design better object-oriented systems with proper coupling and lifecycle management. Composition Composition represents a strong "part-of" relationship where the child object cannot exist independently of the parent object. When the parent is destroyed, all child objects are also destroyed automatically. Composition: Strong Ownership Car (Owner) Engine (Owned) ...

Read More

What is early binding in C#?

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

Early binding in C# is the mechanism of linking a method call with its implementation during compile time. It is also called static binding because the method to be called is determined at compilation rather than at runtime. In early binding, the compiler knows exactly which method will be executed based on the method signature (name, parameters, and their types). This results in faster execution since no runtime resolution is needed. How Early Binding Works C# achieves early binding through static polymorphism, which includes method overloading and operator overloading. The compiler resolves which specific method to call ...

Read More

What are unary operators in C#?

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

Unary operators in C# are operators that operate on a single operand. They perform various operations such as incrementing, decrementing, negating, or getting the size of a data type. Complete List of Unary Operators Operator Name Description + Unary plus Indicates positive value (rarely used) - Unary minus Negates the value ! Logical NOT Inverts boolean value ~ Bitwise complement Inverts all bits ++ Increment Increases value by 1 -- Decrement Decreases value by 1 (type) Cast Converts to ...

Read More

What are user defined data types in C#?

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 3K+ Views

User-defined data types in C# allow developers to create custom types beyond the built-in primitive types. The main user-defined data types in C# are structures, enumerations, classes, interfaces, and delegates. This article focuses on structures and enumerations as fundamental user-defined types. Structure In C#, a structure is a value type data type that helps you group related data of various types into a single unit. The struct keyword is used for creating a structure. Syntax public struct StructName { // fields, properties, methods, constructors public dataType field1; ...

Read More

What is aggregation in C#?

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

Aggregation in C# represents a has-a relationship between objects where one class contains or uses another class. In aggregation, the contained object can exist independently of the container object, making it a weak association. For example, an Employee has an Address, and a Department has multiple Employees. The key characteristic of aggregation is that when the container object is destroyed, the contained objects continue to exist independently. Syntax Following is the syntax for implementing aggregation in C# − public class ContainerClass { private ContainedClass containedObject; ...

Read More
Showing 911–920 of 1,951 articles
« Prev 1 90 91 92 93 94 196 Next »
Advertisements