Skip to main content

Posts

Showing posts with the label Learn-C#

Chapter 1.5: Introduction to C# and the .NET Framework: Understanding Arrays and Collections in C#

 Introduction: In the previous post , we explored control structures in C#, including if/else statements, switch statements, and various looping constructs (for, while, and do/while). In this post, we'll delve into arrays and collections, which are essential data structures for storing and manipulating groups of related data items. After this article, we'll move on to the next chapter: "Object-Oriented Programming with C#." Arrays: An array is a fixed-size, ordered collection of elements of the same data type. The elements in an array can be accessed by their index, which starts from zero. Creating and Initializing Arrays: There are multiple ways to create and initialize arrays in C#. Here are some common examples: Declare an array with a specified size: int [] numbers = new int [5]; Declare and initialize an array with specific values: int [] numbers = { 1, 2, 3, 4, 5 };

Chapter 1.4: Introduction to C# and the .NET Framework: Understanding Control Structures in C# (if/else, switch, for, while, do/while)

 Introduction: In the previous post , we explored the fundamentals of data types, variables, and operators in C#. In this post, we'll dive into control structures, which allow us to control the flow of our program's execution. We will also discuss arrays and collections in the next article. Control Structures: Control structures enable us to make decisions, repeat operations, and perform different actions based on specific conditions. The most common control structures in C# are if/else, switch, for, while, and do/while. if/else: The if/else statement allows us to execute a block of code if a specified condition is true and another block of code if the condition is false. Syntax: if (condition) { // Code to execute if condition is true } else { // Code to execute if condition is false } Example: int age = 18; if (age >= 18) { Console.WriteLine( "You are eligible to vote." ); } else { Console.WriteLine(

Chapter 1.3: Introduction to C# and the .NET Framework: Understanding Data Types, Variables, and Operators in C#

 Introduction: In the previous post, we set up a development environment for C# programming using Notepad++, the .NET Core SDK, and batch files . In this post, we'll explore the fundamentals of data types, variables, and operators in C#. We will also discuss control structures (if/else, switch, for, while, do/while) in the next article. Data Types: Data types define the type of data a variable can store. In C#, there are two main categories of data types: Value Types: Store the actual data. Examples include int, float, double, char, and bool. Reference Types: Store the memory address where the data is located. Examples include string, object, and arrays. Commonly used data types in C#: int: Represents a 32-bit integer. float: Represents a single-precision floating-point number. double: Represents a double-precision floating-point number. char: Represents a single Unicode character. bool: Represents a boolean value (true or false). string:

Chapter 1.2: Introduction to C# and the .NET Framework: Setting up the Development Environment for C# with Notepad++

Introduction In the previous post, we covered the fundamentals of C# and the .NET framework . Now, we'll set up a lightweight development environment for C# programming using Notepad++ as our code editor, the .NET Core SDK for compilation and execution, and batch files to streamline the process. Setting Up the Development Environment: Follow the steps mentioned in the previous post to set up a C# development environment using Notepad++ and the .NET Core SDK. Creating Your First C# Program: Open Notepad++ and create a new file. Save the file with a ".cs" extension, indicating that it's a C# source file. Type the following code: using System; class HelloWorld { static void Main() { Console.WriteLine( "Hello, World!" ); } }

Chapter 1.1: Introduction to C# and the .NET Framework: Overview of C# and .NET

 Introduction Welcome to the first post in our C# Basics series! In this post, we'll explore the fundamentals of C# and the .NET framework, providing you with a solid foundation for diving into C# programming. Throughout this series, we'll be using Notepad++ as our code editor, focusing on understanding the concepts rather than relying on complex development environments. What is C#? C# (pronounced "C Sharp") is a modern, object-oriented programming language developed by Microsoft. Designed for the .NET framework, C# is versatile and powerful, making it ideal for various applications, including web, desktop, mobile, and gaming development. What is .NET? .NET is a software framework developed by Microsoft, providing a runtime environment and a large class library for building, deploying, and running applications. It supports multiple programming languages, including C#, VB.NET, and F#. With .NET, you can create Windows applications, web applications, and service