Back to blogs

May 28, 2026

C# Fundamentals and Object-Oriented Programming

C# Fundamentals and Object-Oriented Programming

Introduction to C# and .NET

  • C# is a versatile, object-oriented programming language developed by Microsoft.
  • It is designed to work within the .NET framework, which supports cross-platform development and a wide range of libraries and tools.

Basic Syntax and Structure

  • C# programs typically consist of one or more classes, which are defined using the class keyword.
  • Every C# program has a Main method, which is the application's entry point.
  • Statements are terminated with a semicolon (;).
  • Comments can be single-line (//) or multi-line (/* */).

Variables and Data Types

  • Variables in C# must be declared with a data type, such as int, float, double, char, string, or bool.
  • Variables can be assigned a value using the assignment operator (=).

Example:

Operators

  • C# supports various operators, including arithmetic (+, -, *, /, %), comparison (==, !=, <, >, <=, >=), logical (&&, ||, !), and assignment (=, +=, -=, *=, /=, %=).

Control Structures

  • C# has several control structures, such as if, else, switch, while, do-while, and for.

Example:

Object-Oriented Programming (OOP) in C#

  • C# supports object-oriented programming with classes, objects, inheritance, polymorphism, and encapsulation.
  • Classes are defined with the class keyword and have properties, methods, and constructors.

Example:

  • Objects are instances of classes created using the new keyword.

Example:

Inheritance

  • Inheritance allows a class to inherit properties and methods from a base class, promoting code reuse and modularity.
  • In C#, inheritance is defined using the : symbol.

Example:

Polymorphism

  • Polymorphism allows methods to have different implementations based on the object they are called on.
  • In C#, polymorphism can be achieved through method overriding (using the override keyword) and interfaces.

Example:

These are the key concepts covered in

the C# Fundamentals and Object-Oriented Programming topics for Week 1, Day 2. Below are some additional topics to be aware of:

Encapsulation

  • Encapsulation is the practice of hiding an object's implementation details and exposing only what is necessary.
  • In C#, encapsulation can be achieved through access modifiers (public, private, protected, and internal) and properties (getters and setters).

Example:

Interfaces

  • Interfaces define contracts that classes can implement, ensuring a consistent structure and behaviour.
  • In C#, interfaces are defined using the interface keyword and are implemented by classes using the : symbol.

Example:

Generics

  • Generics allow you to create type-agnostic classes, methods, and interfaces that work with various data types.
  • In C#, generics are defined using angle brackets (<>) and can be constrained using the where keyword.

Example:

LINQ (Language Integrated Query)

  • Using a consistent syntax, LINQ allows you to query data from various sources (such as collections, databases, and XML files).
  • In C#, LINQ queries can be written using query syntax or method syntax.

Example:

These concepts form the basis of C# programming and object-oriented programming. Be sure to practice and reinforce your understanding with hands-on exercises and projects.

Promact team

We are a family of Promactians

We are an excellence-driven company passionate about technology where people love what they do.

Get opportunities to co-create, connect and celebrate!

Join Us

Vadodara

Headquarter

B-301, Monalisa Business Center, Manjalpur, Vadodara, Gujarat, India - 390011

+91 (932)-703-1275

Ahmedabad

West Gate, B-1802, Besides YMCA Club Road, SG Highway, Ahmedabad, Gujarat, India - 380015

Pune

46 Downtown, 805+806, Pashan-Sus Link Road, Near Audi Showroom, Baner, Pune, Maharashtra, India - 411045

USA

4056, 1207 Delaware Ave, Wilmington, DE, United States America, US, 19806

+91 (932)-703-1275
Promact global office locations on world map