<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Cindy Nguyen</title>
    <description>The latest articles on DEV Community by Cindy Nguyen (@sindwin).</description>
    <link>https://dev.to/sindwin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2519485%2F7518954e-ce47-4abc-aa41-a904cb16082c.png</url>
      <title>DEV Community: Cindy Nguyen</title>
      <link>https://dev.to/sindwin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sindwin"/>
    <language>en</language>
    <item>
      <title>Learning in Reverse: How I Would Learn ASP. Net Core and Entity Framework If I Could Go Back In Time</title>
      <dc:creator>Cindy Nguyen</dc:creator>
      <pubDate>Thu, 19 Dec 2024 18:29:52 +0000</pubDate>
      <link>https://dev.to/sindwin/learning-in-reverse-how-i-would-learn-asp-net-core-and-entity-framework-if-i-could-go-back-in-3l9f</link>
      <guid>https://dev.to/sindwin/learning-in-reverse-how-i-would-learn-asp-net-core-and-entity-framework-if-i-could-go-back-in-3l9f</guid>
      <description>&lt;p&gt;My journey to mastering ASP.NET Core and Entity Framework has been both rewarding and challenging. When I first encountered this powerful C# framework, I felt overwhelmed and uncertain about where to start. But through persistence, trial, and error, I’ve made significant progress. &lt;br&gt;
Looking back, I realize there are several key concepts I wish I had focused on from the beginning. While I can’t rewrite my own learning process (and avoid the risk of a time paradox), I hope to share what I've learned with others who are starting on the same path. My goal is to help you navigate the learning curve more smoothly and make your journey as rewarding as mine has been.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First of all, why learn ASP.NET CORE and Entity Framework? (And what is the difference?)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ASP.NET Core&lt;/strong&gt; is a cross-platform, high-performance framework for building modern full-stack web applications. Its modular architecture and built-in dependency injection make it appealing for C# developers looking to build scalable and maintainable projects through the lenses of Object object-oriented programming.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Entity Framework(EF)&lt;/strong&gt; is an &lt;strong&gt;Object Relation Mapper (ORM)&lt;/strong&gt; that essentially acts as a bridge between the classes (which are objects) in your code and the tables in the database. You can think of tables being represented by your classes, the properties of your class as the columns, and instances as rows. This framework also abstracts much of the SQL querying and uses LINQ more commonly to obtain data.&lt;/p&gt;

&lt;p&gt;EF and ASP.NET Core are not the same. They are distinct components but are often used in conjunction to build full-stack applications. This idea confused me when I first started learning how to create a functioning backend in C#. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Importance of Learning How to Learn&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Learning ASP.NET Core as an autodidact can be daunting, especially without the support of mentors. Success lies in finding the "sweet spot"—tasks just beyond your current abilities, challenging yet achievable with the right resources. Everyone's sweet spot is different, but focusing on concepts that push you without overwhelming you is key to mastering ASP.NET Core.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;1. Understand the General Project Setup and Folder Structure for ASP.NET Core&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;ASP.NET Core applications start with a large but well-defined folder structure to help organize and maintain code as a project can grow; however, at first glance, it can look overwhelming. Understanding this folder structure will be essential to working and learning ASP.NET Core. I’ll give a quick breakdown of this structure along with some short summaries.&lt;/p&gt;

&lt;p&gt;The general structure will look something like this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Controllers/:&lt;/strong&gt; Contains classes that handle HTTP requests and responses. You’ll write your logic for your RESTful API’s here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Models/:&lt;/strong&gt; Defines your data structures, often used with EF to represent database entities. This is where you’ll create your classes that will be mapped into the database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Views/:&lt;/strong&gt; Stores Razor Pages or HTML templates with embedded C#.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data/:&lt;/strong&gt; Includes DbContext and EF-related files for managing database interactions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Program.cs:&lt;/strong&gt; Contains the entry point of your app and you’re expected to configure your services, tools that can be used/”injected” throughout your app,(EF, dependency injections), and request pipeline (middleware) for the application &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;2. Start with the Fundamentals: Learn C# and the Basics of ASP.NET Core&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;ASP.NET Core is built on C#, and understanding the language is the first step toward mastering the framework. If you’re also a JavaScript developer looking to learn to C# and would like a guide, I’ve made a &lt;a href="https://dev.to/sindwin/embark-on-the-code-crusade-a-javascript-developers-venture-into-c-4b7c"&gt;blog post&lt;/a&gt; to help you transition to C# as a Javascript developer. Check it out! You’ll need it to make it this far. Once you’re comfortable with C#, focus on the foundational components of ASP.NET Core:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MVC (Model-View-Controller)&lt;/strong&gt;: Understanding the MVC pattern is essential, as it is the foundation of most web applications in ASP.NET Core. It is an architectural design that will help you plan out projects if you have a solid understanding of it. &lt;br&gt;
In the MVC pattern:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Model:&lt;/strong&gt; Represents the data and the logic of the application (e.g., database entities).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;View:&lt;/strong&gt; Represents the user interface (UI) hence the name “view”, typically using Razor Pages (HTML templates with embedded C#).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Controller:&lt;/strong&gt; Handles user input, interacts with the model, and selects the appropriate view.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dependency Injection:&lt;/strong&gt; This is a key feature of ASP.NET Core and an important concept in object-oriented design. Dependency Injection is a way to give a class the tools (dependencies) it needs without the class creating them. Instead, these dependencies are provided from the outside. This makes the code more flexible and easier to manage. Learning how DI works in ASP.NET Core will help you structure your applications in an organized manner. A good way to understand dependency injection is by comparing it to Polymorphism. While polymorphism allows a class to change its behavior based on the type of object it interacts with (depending on the context), dependency injection provides those behaviors (or dependencies) from an external source, instead of having the class create or manage them internally.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Polymorphism Example&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
The Vehicle class does not store or manage the dependency (IWheel) itself. Instead, it interacts with the provided IWheel only when a method (e.g., TestWheel) is called. The caller determines which implementation of IWheel is passed during each method invocation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Define a common interface for wheels
public interface IWheel
{
    void Rotate();
}

// Implement different types of wheels
public class CarWheel : IWheel
{
    public void Rotate()
    {
        Console.WriteLine("Car wheel is rotating.");
    }
}

public class BikeWheel : IWheel
{
    public void Rotate()
    {
        Console.WriteLine("Bike wheel is rotating.");
    }
}

// The Vehicle class uses polymorphism to interact with different wheel types
public class Vehicle
{
    public void TestWheel(IWheel wheel)
    {
        wheel.Rotate();
    }
}

// Example usage
class Program
{
    static void Main()
    {
        Vehicle vehicle = new Vehicle();

        // Use a car wheel
        IWheel carWheel = new CarWheel();
        vehicle.TestWheel(carWheel);  // Output: "Car wheel is rotating."

        // Use a bike wheel
        IWheel bikeWheel = new BikeWheel();
        vehicle.TestWheel(bikeWheel);  // Output: "Bike wheel is rotating."
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;Dependency Injection&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
The Vehicle class receives and stores the dependency (IWheel) through its constructor. This establishes a persistent relationship between Vehicle and the provided IWheel implementation, which is then used in its methods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Define a common interface for wheels
public interface IWheel
{
    void Rotate();
}

// Implement different types of wheels
public class CarWheel : IWheel
{
    public void Rotate()
    {
        Console.WriteLine("Car wheel is rotating.");
    }
}

// The Vehicle class depends on IWheel and receives it via DI
public class Vehicle
{
    private readonly IWheel _wheel;

    // Constructor injection
    public Vehicle(IWheel wheel)
    {
        _wheel = wheel;
    }

    public void Move()
    {
        _wheel.Rotate();
        Console.WriteLine("Vehicle is moving.");
    }
}

// Example usage
class Program
{
    static void Main()
    {
        // Inject the dependency
        IWheel carWheel = new CarWheel();
        Vehicle car = new Vehicle(carWheel);

        // Move the vehicle
        car.Move();  // Output: "Car wheel is rotating. Vehicle is moving."
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;3. Master Entity Framework Core Basics&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To effectively use EF with ASP.NET Core, focus on:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DbContext:&lt;/strong&gt; DbContext is probably one of the most important concepts/tools you’ll need to understand in EF. DbContext is the main class in EF that acts as a translator between your application and database. It manages the connection and handles changes to the data.  It encapsulates your model classes (representing tables in the database) and translates your C# code into database queries, simplifying how you interact with the database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using Microsoft.EntityFrameworkCore;

public class AppDbContext : DbContext
{
    public DbSet&amp;lt;Product&amp;gt; Products { get; set; }  // Represents the Products table

    // Configuring the database connection string
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        // Replace "YourConnectionStringHere" with your actual database connection string
        optionsBuilder.UseSqlServer("YourConnectionStringHere");
    }
}

using System;
using System.Linq;

public class Program
{
    public static void Main(string[] args)
    {
        using (var context = new AppDbContext())
        {
            // Querying all products
            var products = context.Products.ToList();
            Console.WriteLine("List of Products:");
            foreach (var product in products)
            {
                Console.WriteLine($"Id: {product.Id}, Name: {product.Name}, Price: {product.Price}");
            }

            // Adding a new product
            var newProduct = new Product
            {
                Name = "Laptop",
                Price = 1200.00m
            };

            context.Products.Add(newProduct);  // Add the new product to the DbSet
            context.SaveChanges();  // Save changes to the database

            Console.WriteLine("New product added.");
        }
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Code First Migrations:&lt;/strong&gt; Code First Migrations allow developers to define a database schema using C# model classes and manage changes incrementally.  Unlike manual SQL scripting (as required in tools like Knex.js), EF simplifies the process by automatically generating the database schema and migrations based on your model definitions. After making changes to your models, EF can update the database structure for you, enabling you to manage your database entirely through C# code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//C# example
public class Product
{
    public int Id { get; set; }
    public string Name { get; set; }
    public decimal Price { get; set; }
}

dotnet ef migrations add InitialCreate

dotnet ef database update

//SQL example
CREATE TABLE Product (
    Id INT PRIMARY KEY IDENTITY(1,1), -- Auto-incrementing primary key
    Name NVARCHAR(255) NOT NULL,     -- String with a maximum length of 255 characters
    Price DECIMAL(18, 2) NOT NULL    -- Decimal with precision 18 and scale 2
);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;LINQ Queries:&lt;/strong&gt; LINQ (Language Integrated Query) is a querying language that allows developers to write SQL-like queries directly in C#. At runtime, LINQ queries are translated into raw SQL when interacting with a database through Entity Framework. But for more complex queries, raw SQL can be used alongside LINQ in EF.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//LINQ example
var expensiveProducts = dbContext.Products.Where(p =&amp;gt; p.Price &amp;gt; 100);
//SQL example
SELECT * FROM Products WHERE Price &amp;gt; 100;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;4. Leverage Documentation and Online Resources&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the biggest challenges I faced in the early stages of learning ASP.NET Core was not knowing where to start. While ASP.NET Core resources are abundant, I found that many of them were not beginner-friendly or simply disengaging. CodeCademy was a great resource to learn C# but I found that wasn’t the case for ASP.NET Core. As a result, I spent a lot of time filtering through resources recommended by seasoned C# developers on Reddit for succinct, easy-to-digest material.&lt;/p&gt;

&lt;p&gt;I recommend using the official ASP.NET Core documentation as a primary source of truth and guidance. The team at Microsoft does a great job at breaking down this robust framework not only through documentation but also in videos that are great for people who are visual and auditory learners. For supplementary learning, I found that YouTube has some gems that offer high-quality tutorials and courses.&lt;/p&gt;

&lt;p&gt;Here are the resources I used and recommend:&lt;br&gt;
&lt;a href="https://learn.microsoft.com/en-us/shows/back-end-web-development-with-dotnet-for-beginners/" rel="noopener noreferrer"&gt;Microsoft's Back-end Web Development for Beginners&lt;br&gt;
&lt;/a&gt;&lt;br&gt;
&lt;a href="https://learn.microsoft.com/en-us/ef/core/get-started/overview/first-app?tabs=netcore-cli" rel="noopener noreferrer"&gt;Microsoft's Entity Framework Tutorial Document&lt;br&gt;
&lt;/a&gt;&lt;br&gt;
&lt;a href="https://youtube.com/playlist?list=PLdo4fOcmZ0oXCPdC3fTFA3Z79-eVH3K-s&amp;amp;si=dw56Y7LbVzjOhLzj" rel="noopener noreferrer"&gt;Microsoft's Entity Framework Youtube Playlist&lt;br&gt;
&lt;/a&gt;&lt;br&gt;
&lt;a href="https://youtu.be/AhAxLiGC7Pc?si=_CaapQg6BmxHoIFQ" rel="noopener noreferrer"&gt;Full Course on ASP.NET by Julio Casal&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;5. Embrace Iterative Learning&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There were times when learning ASP.NET Core felt like a time loop, rewatching tutorials or courses multiple times. But persistence is key. It’s easy to get discouraged when things aren’t clicking, but improvement comes from iterating on what confuses you and learning from mistakes. Rewatch that Dependency Injection video, redo the same tutorial, or find a new resource to reinforce key concepts. As a software developer, problem-solving and persistence are essential skills that will help you succeed with ASP.NET Core.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Looking back on my journey to learn ASP.NET Core, I can confidently say that persistence, trial and error, and a willingness to embrace challenges were key to my progress. When I first encountered ASP.NET Core, it felt overwhelming and uncertain. But by breaking it down into manageable steps, following along side tutorials, and asking questions, I was able to make the transition. Learning is a continuous journey—ASP.NET Core may seem complex at first, but once you find your learning sweet spot, it becomes a rewarding experience.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>aspnet</category>
      <category>backend</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>Embark on the Code Crusade: A JavaScript Developer’s Venture into C#</title>
      <dc:creator>Cindy Nguyen</dc:creator>
      <pubDate>Tue, 03 Dec 2024 19:09:37 +0000</pubDate>
      <link>https://dev.to/sindwin/embark-on-the-code-crusade-a-javascript-developers-venture-into-c-4b7c</link>
      <guid>https://dev.to/sindwin/embark-on-the-code-crusade-a-javascript-developers-venture-into-c-4b7c</guid>
      <description>&lt;p&gt;Do you want to sharpen your coding sword? Step into the dynamic world of C#.  In this blog post, I’ll guide you through the transition from JavaScript to C#. As a JavaScript developer, you're about to embark on a thrilling journey through new syntax lands, past the towers of strict typing, and into the dungeons of object-oriented programming. We’ll explore why C# is worth learning, then compare it with JavaScript to highlight key similarities and differences. Along the way, I'll provide essential syntax examples to help you get started. Ready to conquer the challenges and emerge as a multi-language coding hero? Let the adventure begin!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why C#?&lt;/strong&gt;&lt;br&gt;
C# is a versatile, high-level language developed by Microsoft. It is widely used in game development, enterprise software, and cross-platform applications.&lt;br&gt;
&lt;strong&gt;Why is C# so popular?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Game Development: Its seamless integration with the Unity game engine has made it a favorite for game developers. Which is why I decided to learn it!&lt;/li&gt;
&lt;li&gt;Enterprise Applications: It’s the go-to language for building desktop, web, and cloud-based applications due to the .NET framework&lt;/li&gt;
&lt;li&gt;Cross-Platform Development: C# is used in frameworks that allow developers to create applications that work on Windows, macOS, Linux, iOS, and Android.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;C# is the perfect balance between being easy to learn and packed with powerful features, making it the ultimate tool for leveling up your development skills and conquering new coding challenges!&lt;br&gt;
Now that you know why C# is worth learning, let’s get into some basic syntax and compare it with JavaScript. This will give you a better understanding of how to translate your knowledge of JavaScript into your new C# development journey.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tighten your grip on data types and variables&lt;/strong&gt;&lt;br&gt;
In C#, you'll find a much stricter approach to handling data types and variables compared to JavaScript. Here’s why:&lt;br&gt;
C# is known as a statically-typed, strongly-typed language– meaning every variable must have a clear and specific data type (e.i string, int, bool, etc) that it sticks to throughout the code. This ensures you can’t perform operations that mix incompatible types—if you try, the program will throw an error before it even runs.&lt;/p&gt;

&lt;p&gt;Whereas JavaScript allows variables to hold values of any type and even change their type later. JavaScript's implicit type coercion can sometimes lead to unexpected behavior, like adding a number-typed variable to a string without warning.&lt;/p&gt;

&lt;p&gt;Syntaxally, in C# you would be replacing the keywords let or const with the appropriate data type. This change is something that still trips me up and sometimes frustrates me since I’m used to Javascript’s flexibility. But this rigorous system in C# serves a purpose: to catch type-related bugs earlier in development.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Javascript example
let value = 42; //Value starts off as an integer
console.log(value + 10); // Output: 52
value = "Hello"; //Now value is declared as a string
console.log(value + 10); 
// Output: "Hello10" due to implicit coercion

//C# example
int value = 42; // Value is initialized as an integer
Console.WriteLine(value + 10); //Output: 52
value = value + "10";
//ERROR! Cannot add an int and string; mismatch data
value = "Hello";
//ERROR! value is defined as an int, no strings allowed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Functions and Coding Blocks&lt;/strong&gt;&lt;br&gt;
Functions in both languages are used to encapsulate logic, but in C#, just like with variables, you need to state a function's return type explicitly. This contrasts with JavaScript, where functions don’t require a declared return type. &lt;/p&gt;

&lt;p&gt;One of the biggest differences is that C# requires all code, including functions, to exist within a class. Even the simplest program must include a class and a "Main" method as the entry point. Unlike JavaScript, where you can write functions directly in the global scope, C# structures everything around classes. This design is due to the fact that C# is an &lt;strong&gt;object-orientated language&lt;/strong&gt;, with classes every piece of code belongs to an object.&lt;/p&gt;

&lt;p&gt;It’s safe to say, that if you want to get comfortable with C#, you’ll need to get comfortable with class structures and object-orientated programming.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Javascript example
// A function without a declared return type
function addNumbers(a, b) {
    return a + b; // Automatically determines the return type
}

// Call the function directly in the global scope
const result = addNumbers(5, 3);
console.log("The result is: " + result);


//C# example
using System;

class Program // Class where our code exists
{
    // A function with an explicit return type
    static int AddNumbers(int a, int b)
    {
        return a + b; // Returns an integer
    }

    static void Main(string[] args) // Entry point
    {
        int result = AddNumbers(5, 3);
        Console.WriteLine("The result is: " + result);
    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Arrays, Lists, and Objects&lt;/strong&gt;&lt;br&gt;
When translating LeetCode solutions from JavaScript to C#, I quickly realized that just because two things share a name doesn’t mean they’re the same. For example, JavaScript arrays are more like C# Lists — flexible in size and typing, with built-in methods. C# arrays, on the other hand, are fixed-size and strictly typed, requiring LINQ for data manipulation. To handle key-value pairs in C#, you’d use a Dictionary, not an object. Unlike JavaScript, where objects are simply key-value pairs, C# objects are the base class for all data types.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Javascript examples
// Arrays in JavaScript (flexible size and type)
let numbers = [1, 2, 3, "four"];
numbers.push(5); // Add an element
console.log(numbers); // [1, 2, 3, "four", 5]

// Key-value pairs with an object
let person = {
    name: "Alice",
    age: 30
};
console.log(person.name); // Access by key: "Alice"

// Add a new key-value pair
person.city = "New York";
console.log(person); // { name: "Alice", age: 30, city: "New York" }


//C# examples
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        // Arrays in C# (fixed size, strictly typed)
        int[] numbers = { 1, 2, 3 };
        // numbers[3] = 4; // Error: Out of bounds
        Console.WriteLine(string.Join(", ", numbers)); // 1, 2, 3

        // Lists in C# (flexible size and typed)
        List&amp;lt;object&amp;gt; mixedList = new List&amp;lt;object&amp;gt; { 1, 2, 3, "four" };
        mixedList.Add(5); // Add an element
        Console.WriteLine(string.Join(", ", mixedList)); // 1, 2, 3, four, 5

        // Dictionary for key-value pairs
        Dictionary&amp;lt;string, object&amp;gt; person = new Dictionary&amp;lt;string, object&amp;gt;
        {
            { "name", "Alice" },
            { "age", 30 }
        };
        person["city"] = "New York"; // Add a new key-value pair
        Console.WriteLine(person["name"]); // Access by key: Alice
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Loops&lt;/strong&gt;&lt;br&gt;
From what I know, loops keep very similar syntax across both languages so… yay!&lt;br&gt;
Initialize(remember to initialize with the data type in C#), Condition, increment!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Javascript loop
for (let i = 0; i &amp;lt; 10; i++){
console.log(i);
}

//C# loop
for (int i = 0; i &amp;lt; 10; i++){
Console.WriteLine(i);
}
//remember, every time you initialize a variable 
//you must assign it a data type 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The Key Differences Between C# and JavaScript&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Typing:&lt;/strong&gt; C# is static and strict Vs JavaScript is dynamic and flexible.&lt;br&gt;
&lt;strong&gt;Model:&lt;/strong&gt; C# is class-based OOP Vs JavaScript is prototype-based and multi-paradigm.&lt;br&gt;
&lt;strong&gt;Compilation:&lt;/strong&gt; C# is precompiled Vs JavaScript is executed line-by-line during runtime.&lt;br&gt;
&lt;strong&gt;Syntax:&lt;/strong&gt; C# enforces strict rules Vs JavaScript is more forgiving.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tips for learning C# as a Javascript Developer&lt;/strong&gt;&lt;br&gt;
It’s dangerous to go alone! Take these strategies to make the learning process smoother:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Leverage your Object-orientated programming knowledge&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
C# is designed around classes and object-oriented principles. Since JavaScript also supports object-oriented programming with prototypes and ES6 classes, your existing understanding will make it easier to pick up C#, even though the two languages handle OOP differently.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Start with the basics&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Familiarize yourself with the syntax differences, especially for variable declarations and functions. Unlike JavaScript, C# is a compiled language that enforces type safety, so you'll need to be more intentional with your code to avoid errors. Getting comfortable with these fundamentals early on will save you headaches down the road.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Use comparisons to help bridge the gaps&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Creating a comparison chart between C# and JavaScript can help you clearly see their similarities and differences. It’s easier to understand new concepts when you have a familiar reference point. Plus, this approach highlights features unique to C#, like namespaces, access modifiers, and LINQ, which don’t have direct equivalents in JavaScript.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Practice with simple, small projects&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
If you want to get comfortable with C# quickly, building small console applications is the way to go. These projects let you practice using conditions, loops, arrays, and classes without feeling overwhelmed. I find the official documentation to be needlessly complicated and convoluted– making it easy to get discouraged when you’re trying to learn. Hands-on coding is the best way to build confidence and understanding!&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;br&gt;
Here are some FREE resources that might come in handy when trying to learn C#:&lt;br&gt;
&lt;a href="https://www.codecademy.com/enrolled/paths/build-web-apps-with-asp-net" rel="noopener noreferrer"&gt;CodeCademy’s C# and .NET Course&lt;br&gt;
&lt;/a&gt;&lt;br&gt;
&lt;a href="https://learn.microsoft.com/en-us/shows/c-fundamentals-for-absolute-beginners/" rel="noopener noreferrer"&gt;Microsoft’s C# Fundamentals for Absolute Beginners&lt;br&gt;
&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/cs/index.php" rel="noopener noreferrer"&gt;W3School’s C# Tutorial&lt;br&gt;
&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.programiz.com/csharp-programming/getting-started" rel="noopener noreferrer"&gt;Programiz’s C# Section&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
While the transition from JavaScript to C# may feel like arduously stepping into a much stricter realm in the programming world, the journey will be well worth it. By leveraging your JavaScript knowledge and embracing C#’s unique features, not only will you become a diverse developer but you will also gain skills that are highly valued in the industry. So go forth and conquer C#! &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>csharp</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
