C#  

C# Fundamentals

Before learning ASP.NET Core, you MUST understand C#. Think of C# as your language and ASP.NET Core as the framework built on top of it.

Let’s go one by one.

1. Variables and Data Types

Variables store values in memory.

Example (Real-time)

Imagine you are creating a User Registration form .

You need variables like:

  
    string fullName = "Sandhiya";
int age = 23;
double salary = 25000.50;
bool isActive = true;
  

Practice

Create variables for:

  • ProductName

  • Price

  • Quantity

  • IsAvailable

2. OOP Concepts (Very Important!)

Classes & Objects

Class = Template
Object = Real item created from template

Real-Time Example

A class called User in a login/signup page:

  
    public class User
{
    public string FullName { get; set; }
    public string Email { get; set; }
    public string Password { get; set; }
}
  

Creating an object :

  
    User u = new User();
u.FullName = "Sandhiya";
u.Email = "[email protected]";
  

3. Inheritance

One class reuses another class.
Useful in real projects.

Real-Time Example

You have common fields for all users:

  
    public class BaseEntity
{
    public int Id { get; set; }
}
  

Now Admin class inherits:

  
    public class Admin : BaseEntity
{
    public string Role { get; set; }
}
  

4. Polymorphism

Same method, different behaviors.

Real Example

Different types of users log in differently.

  
    public class LoginService
{
    public virtual void Login() => Console.WriteLine("Normal Login");
}

public class AdminLogin : LoginService
{
    public override void Login() => Console.WriteLine("Admin Login with OTP");
}
  

5. Abstraction

Hiding unnecessary details.

Real-Time Example

You drive a bike, but you don’t know internal engine details.
Same way:

  
    public abstract class Payment
{
    public abstract void Pay();
}
  

6. Interfaces

A contract / rule.
Used massively in ASP.NET Core.

Real-Time Example (Dependency Injection)

In Core we use interfaces for services.

  
    public interface IEmailService
{
    void SendEmail(string to, string message);
}

public class GmailService : IEmailService
{
    public void SendEmail(string to, string message)
    {
        Console.WriteLine("Mail sent using Gmail");
    }
}
  

7. Collections: List & Dictionary

Used instead of arrays.

Real-Time Example

Keep list of registered users.

  
    List<User> users = new List<User>();
users.Add(new User { FullName = "Sandhiya", Email = "[email protected]" });
  

Dictionary → Key-value pair.

  
    Dictionary<string, string> settings =
    new Dictionary<string, string>();

settings["SiteName"] = "MyWebsite";
  

8. LINQ (Must Know Before Core)

You cannot work with Core without LINQ.
LINQ helps filter, search, sort.

Real-Time Example

Search user by email.

  
    var user = users.FirstOrDefault(u => u.Email == "[email protected]");
  

Filter active users:

  
    var activeUsers = users.Where(u => u.IsActive == true).ToList();
  

9. Practice Task (MOST IMPORTANT)

Create a C# Console App performing CRUD using List.

Model

  
    public class Product
{
    public int Id { get; set; }
    public string Name { get; set; }
    public double Price { get; set; }
}