Day 6 – Introduction to C#: Core Syntax and Features Every Developer Must Know

Introduction

C# (pronounced C-Sharp) is the backbone of the .NET ecosystem, powering applications ranging from enterprise software to web apps and games. For any aspiring FullStack .NET developer, mastering C# core syntax and features is the first critical step. At Curiosity Tech, we guide developers with hands-on training that merges theory with real-world projects, ensuring learners don’t just understand concepts but can apply them immediately.

1. Understanding C# Structure

C# is object-oriented, type-safe, and modern. Its syntax is similar to Java and C++, making it approachable for developers transitioning from other languages. A simple C# program:

using System;

namespace HelloWorldApp

{

    class Program

    {

        static void Main(string[] args)

        {

            Console.WriteLine(“Hello, CuriosityTech.in learners!”);

       

   

ComponentDescription
using SystemImports the System namespace containing fundamental classes
namespaceOrganizes code into reusable modules
class ProgramDefines a class named Program
Main methodEntry point of the application
Console.WriteLinePrints text to the console

2. Variables and Data Types

C# is strongly typed, meaning every variable has a type. Common types include:

TypeExampleDescription
intint age = 25;Whole numbers
doubledouble price = 99.99;Floating-point numbers
stringstring name = “Bhavesh”;Textual data
boolbool isActive = true;True/False values
charchar grade = ‘A’;Single character

Tip: Using proper data types optimizes memory and improves code readability.


3. Operators in C#

Operators perform operations on variables and values:

  • Arithmetic: + – * / %
  • Comparison: == != > < >= <=
  • Logical: && || !

Example:

int a = 10;

int b = 5;

Console.WriteLine(a + b); // 15

Console.WriteLine(a > b); // True


4. Control Flow

C# uses standard control flow statements:

If-Else Example:

int score = 85;

if (score >= 90)

{

    Console.WriteLine(“Grade A”);

}

else if(score >= 75)

{

    Console.WriteLine(“Grade B”);

}

else

{

    Console.WriteLine(“Grade C”);

}

Loops:

  • for loop: Iterate fixed times
  • while loop: Iterate while condition is true
  • foreach loop: Iterate over collections

5. Methods and Functions

Methods organize code into reusable blocks.

int Add(int x, int y)

{

    return x + y;

}

Console.WriteLine(Add(5, 10)); // 15

  • Return type specifies what the method returns (int in this case)
  • Parameters allow passing data

6. Classes and Objects

C# is object-oriented, meaning you can model real-world entities using classes and objects.

class Car

{

    public string Brand;
public int Year
public void Start()

   

    {

        Console.WriteLine($”{Brand} car started.”);

    }

}

Car myCar = new Car();

myCar.Brand = “BMW”;

myCar.Year = 2022;

myCar.Start(); // BMW car started.

Diagram:


7. CuriosityTech.in’s Approach

At Curiosity Techn, learners don’t just memorize syntax. Our hands-on exercises include:

  • Mini projects for CRUD operations
  • Real-world examples to implement OOP principles
  • Step-by-step mentorship to ensure learners are ready for Day 7: Object-Oriented Programming in C#

Conclusion

Mastering C# core syntax and features lays a strong foundation for .NET FullStack development. By combining theory, practical examples, and mentorship from Curiosity Tech, you’ll build confidence to create robust applications. The next step is diving deeper into OOP concepts, which form the backbone of scalable .NET solutions.


Leave a Comment

Your email address will not be published. Required fields are marked *