Posts

Showing posts with the label Programming Language

Structures in C #

Structures in C# In C#, a structure (struct) is a value type that encapsulates data members and member methods. It's a user-defined data type that allows you to create custom data structures tailored to specific needs. Key Characteristics of Structures:  * Value Type: When you declare a variable of a struct type, the actual data is stored directly in the variable. This means that when you assign a struct to another variable, a copy of the data is created.  * No Inheritance: Structures cannot inherit from other structures or classes.  * Default Constructor: Structures have a default parameterless constructor that initializes all members to their default values.  * No Destructor: Structures don't have destructors. The garbage collector automatically reclaims memory used by structures when they are no longer needed. Declaring a Structure: struct Point {     public int X;     public int Y;     public void Display()     {   ...

Functions in C#

Functions in C# In C#, functions are blocks of code that perform specific tasks. They are essential for breaking down complex programs into smaller, more manageable units. This modular approach improves code readability, reusability, and maintainability. Basic Structure of a Function: [access_modifier] return_type function_name(parameter_list) {     // Function body     // ...     return value; // Optional, if return_type is not void } Key Components:  * Access Modifier:    * public: Accessible from anywhere.    * private: Accessible only within the same class.    * protected: Accessible within the same class and its derived classes.    * internal: Accessible within the same assembly.  * Return Type:    * Specifies the data type of the value returned by the function.    * void: Indicates that the function doesn't return any value.  * Function Name:    * A unique identifier ...

C# Logical Operators

C# Logical Operators Logical operators in C# are used to combine boolean expressions and produce a single boolean result. They are essential for making complex decisions within your code. Types of Logical Operators:  * Logical AND (&&)    * Returns true if both operands are true.    * Returns false otherwise.    bool isSunny = true; bool isWarm = true; if (isSunny && isWarm) {     Console.WriteLine("It's a perfect day for a picnic!"); }  * Logical OR (||)    * Returns true if at least one operand is true.    * Returns false if both operands are false.    bool hasMoney = false; bool hasCreditCard = true; if (hasMoney || hasCreditCard) {     Console.WriteLine("You can make a purchase."); }  * Logical NOT (!)    * Reverses the logical state of its operand.    * Returns true if the operand is false.    * Returns false if the operand is true.   ...

C# Control Statements

Control Statements Introduction to Control Statements ➡ A control statement is responsible for deciding which statement to execute (If Statement) ➡It also decides the number of times a statement has to be executed (Loop) ➡SELECTION: Checks condition of an expression and executes only a particular code skipping the others ➡ITERATION: Checks condition of an expression and executes a particular code repeatedly till the expression becomes false