Shiva Gautam C# .NET Foundation Builder

Build a structured, practical understanding of C# under the .NET ecosystem — from environment setup to object-oriented program architecture — that you can immediately apply to write, compile, and run real programs.

// TL;DR

The Shiva Gautam C# .NET Foundation Builder is a structured learning framework for mastering C# under the .NET ecosystem — from environment setup to object-oriented program architecture. It teaches you that .NET is a platform (not a language), that C# is its most compatible language, and how the CIL → CLR → OS compilation pipeline works. Use it when you're starting C# from scratch or structuring a teaching session covering syntax, variables, data types, methods, and object-oriented basics. Its core discipline: subdivide every task into methods, keep Program.cs for calling only, and always code, compile, and run — practicals over theory.

// When should you use the C# .NET Foundation Builder?

Use this skill when a learner is starting C# or .NET development from scratch, or when you need to structure a teaching or self-study session covering .NET platform concepts, C# syntax, variables, data types, methods, and object-oriented basics.

// What do you need before starting to learn C# with this framework?

  • Learner's goalrequired
    What the learner wants to build (e.g., desktop app, web app, API, mobile app) or which topic they need to master.
  • Current knowledge levelrequired
    Whether the learner has prior programming experience or is a complete beginner.
  • Development environment
    Whether Visual Studio 2022 Community Edition is installed, or if the learner is starting from Notepad/command prompt.
  • Specific program or task
    A concrete program the learner wants to implement (e.g., calculator, simple interest, swap two numbers).

// What core principles drive effective C# and .NET learning?

.NET is a Platform, Not a Language

.NET is a technology platform that provides a workspace, set of libraries, and features for developing multiple types of applications using multiple programming languages. C# is not .NET — C# is the most compatible programming language under the .NET framework.

C# is the Most Compatible Language Under .NET

C# is a fully object-oriented programming language whose syntax structure mirrors Java. It provides better security, reusability of code, and an easy syntax structure for developers. In 99% of .NET projects, C# is the language used.

Practicals Over Theory

Theoretical content is available everywhere. The real skill is built through practical implementation. Every concept must be coded, compiled, and executed — not just read or watched.

Sub-divide Every Task into Methods

Every individual task in a program must be placed inside its own method/function. This enables calling specific functionality on demand, supports inheritance, enables code reuse, and makes the program maintainable.

Static vs. Non-Static (Instance) Memory Rule

Static components are called via Class Name — their memory is allocated at compile time. Non-static (instance) components are called via an Object — their memory is allocated at runtime using the 'new' keyword. 99% of real programs use non-static/instance types.

Main Method is the Entry Point

Every C# program's execution begins at the Main method (public static void Main). This prototype is fixed and cannot be changed. Visual Studio generates this automatically, but a developer must understand it structurally.

CIL → CLR → OS Execution Pipeline

C# source code is compiled by the C# compiler (csc) into Common Intermediate Language (CIL) code, not directly into binary. The Common Language Runtime (CLR) then converts CIL into binary code and sends it to the Operating System for execution.

Program.cs is Only for Calling

The Program.cs file containing Main is only for calling (invoking) methods. All logic — arithmetic, input handling, calculations — must be placed in separate, well-named classes and methods. Main should never contain business logic directly.

Boxing and Unboxing

Boxing is converting a value type (e.g., int, float, char) to a reference type (object) — also called implicit conversion. Unboxing is converting a reference type (object) back to a value type — also called explicit conversion. Use object type when the incoming data type is undefined or variable.

Access Modifiers Control Scope

private: accessible only within the same class. internal: accessible across classes within the same project. public: accessible across projects. protected and protected internal also exist. Default for methods is private — always explicitly set the modifier.

// How do you learn C# step by step from setup to object-oriented programs?

  1. 1

    Establish the .NET platform context

    Confirm the learner understands: .NET is a platform (not a language), it supports 90+ languages, C# is the most compatible. Identify which application type they are targeting: Desktop (Console App, Windows Forms, WPF), Web (ASP.NET Core MVC), Mobile (MAUI), Cloud (Azure), or API (Web API). This determines which framework layer they will eventually reach.

  2. 2

    Set up the development environment

    Install Visual Studio 2022 Community Edition (free). Minimum requirements: Windows 10/11, 4GB RAM, 20-25GB disk space, i3 processor minimum (i5/i7 preferred). Distinguish clearly: VS Code is for front-end; Visual Studio is for .NET back-end. Do not conflate the two.

  3. 3

    Demonstrate the Notepad → Command Prompt compilation flow first

    Before using Visual Studio, have the learner write a minimal C# program in Notepad (.cs extension), set the PATH to the .NET framework directory (C:\Windows\Microsoft.NET\Framework\v4.x), compile using 'csc filename.cs', and execute the resulting .exe. This reveals the CIL → CLR → OS pipeline that Visual Studio hides. Do this for exactly one program, then move to Visual Studio permanently.

  4. 4

    Create a Console Application project in Visual Studio

    File > Create New Project > Console Application (select C# / Linux / Mac / Windows). Name the project (e.g., 'ProjectPractice'). Select the latest .NET Core framework version (e.g., .NET 9.0). Do NOT create a new project for every session — one project, multiple classes added via right-click > Add > New Item.

  5. 5

    Explain and write the mandatory C# program structure

    Every program requires: (1) using System; — imports the System namespace. (2) namespace — logical container, first letter capitalised. (3) class — named container for methods. (4) public static void Main(string[] args) — the fixed entry point prototype. Console.WriteLine() is used to print to the console screen. This structure is non-negotiable syntax.

  6. 6

    Introduce variables, constants, and literals

    Variables hold data that can change dynamically; declared with a DataType and Identifier (e.g., int a = 10). Constants use the 'const' keyword — their value cannot be reassigned after declaration; compile-time error if you try. Literals are the actual values assigned (e.g., 'Hello', 10, 12.34, true — these are string, integer, float, and boolean literals respectively). var is the undefined/untyped variable — not type-safe; use object instead when type safety matters.

  7. 7

    Classify variables by scope and memory allocation

    By scope: Global (declared at class level) vs. Local (declared inside a method). By memory allocation: Static (compile-time memory, called via ClassName) vs. Non-static/Instance (runtime memory, called via Object). Rule: 99% of real programs use non-static/instance variables. Static variables should only be used when you deliberately want shared compile-time memory.

  8. 8

    Introduce data types: Primitive vs. Derived

    Primitive types: inherited from C/C++ — int, float, char, double, bool, string (lowercase). Derived/Reference types: .NET-defined — Int16, Int32, Int64, String (capital S), Object, custom classes. Object is the root class of all .NET types — it can contain any type of data (use when data type is unknown). String is both primitive (lowercase) and derived (capital). Char holds a single character (2 bytes); string is a collection of characters.

  9. 9

    Explain Boxing and Unboxing with code examples

    Boxing: assign a value type (e.g., int) to an object variable — implicit conversion. Example: object o = a; Unboxing: cast the object back to a value type — explicit conversion (casting required). Example: int x = (int)o; Use boxing/unboxing only when the data type is genuinely unknown at design time. Prefer typed variables otherwise.

  10. 10

    Build programs using the Method-per-Task pattern

    For every task (addition, subtraction, simple interest, etc.): (1) Create a new class (right-click project > Add > New Item > Class). (2) Give the class a meaningful name. (3) Set the access modifier to 'internal' (same project) or 'public' (cross-project). (4) Create one method per task inside that class. (5) In Program.cs Main method: create an object of the class (ClassName obj = new ClassName();) and call the method (obj.MethodName();). Program.cs Main is ONLY for calling — never put logic there.

  11. 11

    Add user input handling via Console.ReadLine()

    Console.ReadLine() returns a string. If the variable is int, you must convert: use Convert.ToInt32(Console.ReadLine()) for integers, Convert.ToDouble() for doubles, etc. The Convert class is the standard C# tool for type conversion. Always accept input in a dedicated method (e.g., void Accept()) and call it before the calculation method.

  12. 12

    Build, execute, and debug using Visual Studio tools

    Build (compile): Ctrl+Shift+B or Build menu. Execute: Green play button. Solution Explorer: View > Solution Explorer to navigate classes. Output window shows build success/failure messages. If a method is private, Visual Studio greys it out — always set the correct access modifier. Never use 'private' for methods you need to call from outside the class.

  13. 13

    Assign and review practice programs

    After each concept, assign programs for independent implementation: (1) Simple Interest calculator, (2) Compound Interest calculator, (3) Area of Circle and Triangle, (4) Feet to Inches and Inches to Feet converter, (5) Reverse a three-digit number, (6) Swap two numbers using a third variable. Review solutions in the next session before proceeding to the next topic.

// What are real examples of applying the C# method-per-task pattern?

A beginner wants to build a basic calculator that performs addition, subtraction, multiplication, and division.

Create one class called 'Calculator'. Inside it, create four internal methods: Add(), Subtract(), Multiply(), Divide(). Declare global variables a and b. Create a separate Accept() method that uses Console.ReadLine() with Convert.ToInt32() to capture user input. In Program.cs Main: create an object (Calculator obj = new Calculator()), call obj.Accept() first, then call whichever operation the user needs. Do NOT put all four operations in Main — each operation is only executed when its method is called.

A learner needs to understand why some methods are called with a class name and others with an object.

Demonstrate with two methods in the same class: one marked 'static void Fun()' and one marked 'void FunctionOne()'. The static method is called via ClassName.Fun() — no object needed, memory allocated at compile time. The non-static method requires: ClassName obj = new ClassName(); then obj.FunctionOne(). Visually confirm in Visual Studio that private methods appear greyed-out, and that changing to internal makes them accessible.

A developer needs to swap two values stored in variables.

Use three variables: a = 5, b = 10, temp. Steps: temp = a (backup a), a = b (overwrite a with b), b = temp (restore original a into b). Analogy: two bottles of water, one hot and one cold — to swap contents you need a third empty bottle. Create a method 'void Swap()' inside a class 'SwapProgram', mark it internal, use static global variables if the task specifies static scope. Call it from Main via an object.

// What common mistakes should C# beginners avoid?

  • Confusing Visual Studio Code (front-end editor) with Visual Studio (full .NET IDE) — they are completely different tools for different purposes.
  • Writing all logic directly inside the Main method instead of creating separate classes and methods per task.
  • Forgetting to set an access modifier — methods are private by default, making them inaccessible from outside the class. Always explicitly set internal or public.
  • Trying to call a non-static (instance) method without first creating an object — instance methods ALWAYS require an object.
  • Trying to call a static method via an object instead of the class name — static methods are always called via ClassName.MethodName().
  • Not converting Console.ReadLine() output before assigning to a typed variable — ReadLine() returns string; use Convert.ToInt32(), Convert.ToDouble() etc. to match the target variable's type.
  • Creating a new Visual Studio project for every practice session — one project supports unlimited classes; add new classes via right-click > Add > New Item.
  • Treating var as a safe or typed alternative to object — var is untyped and not type-safe; use object when a typed container for unknown data is needed.
  • Trying to reassign a value to a const variable — constants cannot be overwritten after declaration; this causes a compile-time error.
  • Skipping the Notepad/command-prompt compilation exercise — without it, the CIL → CLR → OS pipeline remains invisible and the learner will not understand what Visual Studio is actually doing behind the scenes.

// What key C# and .NET terms should you know?

.NET
A technology platform (not a programming language) used to create multiple types of applications using a framework and compatible programming languages. Supports 90+ languages; C# is the most compatible.
.NET Core Framework
The open-source, cross-platform version of .NET that runs on Windows, macOS, and Linux without requiring a license. The actively updated framework as of 2025 (latest: .NET 9.0).
C# (C Sharp)
The most compatible, fully object-oriented programming language under the .NET framework. Mirrors Java's syntax structure and is used in 99% of .NET projects.
CIL (Common Intermediate Language)
The intermediate code produced when C# source code is compiled. It is not binary — it is a platform-neutral code that the CLR then converts to binary for the OS.
CLR (Common Language Runtime)
The .NET runtime environment that takes CIL code, converts it to binary, and sends it to the Operating System for execution.
csc
The C# Compiler command used in Command Prompt to compile a .cs file into a .exe (via CIL). Example: 'csc hello.cs'.
Console Application
A command-based application type used for learning C# — all input and output happens via the console (black screen). Best for mastering language fundamentals before moving to GUI or web applications.
Visual Studio 2022 Community Edition
The free IDE (Integrated Development Environment) tool that provides a complete platform to create, compile, debug, execute, and deploy .NET applications. Distinct from VS Code.
Namespace
A logical container in C# that groups related classes. First letter is always capitalised. Example: 'using System;' imports the System namespace.
Main Method
The fixed entry point of every C# program: 'public static void Main(string[] args)'. Execution always begins here. This prototype cannot be changed. In standard practice, Main is used only for calling other methods.
Static vs. Non-Static (Instance)
Static components are called via ClassName and have memory allocated at compile time. Non-static/instance components require an object (created with 'new') and have memory allocated at runtime. 99% of real-world programs use instance types.
Global Variable
A variable declared at class level (outside any method). Can be static or non-static. Accessible throughout the class.
Local Variable
A variable declared inside a method or function. Only accessible within that method.
Const (Constant)
A special identifier whose value cannot be changed after initial assignment. Declared with the 'const' keyword before the data type. Attempting reassignment causes a compile-time error.
Literal
The actual data value assigned to a variable or constant. Examples: 'Hello' (string literal), 10 (integer literal), 12.34 (float literal), true (boolean literal).
Primitive Data Type
Data types inherited from C/C++ that are supported by C# — includes int, float, char, double, bool, string (lowercase). These are why C# is not considered 100% pure object-oriented.
Derived Data Type
Data types defined under the .NET framework — includes Int16, Int32, Int64, String (capital S), Object, and custom classes. All derive from the Object root class.
Object (root class)
The ultimate base class of all .NET types. Any data type — primitive or derived — is ultimately a subtype of Object. Used as a universal container when the data type is unknown at design time.
Boxing
Converting a value type (e.g., int, float, char) to a reference type (object). Also called implicit conversion. Example: object o = a; where a is an int.
Unboxing
Converting a reference type (object) back to a value type. Also called explicit conversion — requires explicit casting. Example: int x = (int)o;
Access Modifier
Keywords that control the scope of a class member. private: within the same class only. internal: across the same project. public: across projects. protected and protected internal also exist.
Solution Explorer
The Visual Studio panel (View > Solution Explorer) used to navigate the project structure — classes, files, and project settings.
MAUI (Multi-platform Application UI)
The .NET framework for building iOS and Android mobile applications using C#. The current replacement for Xamarin.
ASP.NET Core MVC
The current (latest) .NET framework for building web applications. ASP.NET Classic and ASP.NET MVC are older predecessors still in use at some companies.
Web API
The .NET tool used to build API-based applications that communicate data between front-end (React, Angular) and database layers. The API acts as the communicator (data carrier) in modern application architecture.
Convert Class
A built-in C# class used to convert between data types. Example: Convert.ToInt32(string) converts a string from Console.ReadLine() to an integer. Used whenever Console.ReadLine() output must be assigned to a typed variable.

// FREQUENTLY ASKED QUESTIONS

What is the difference between .NET and C#?

.NET is a technology platform that provides a workspace, libraries, and features for building multiple types of applications using 90+ programming languages. C# is not .NET — it is the most compatible programming language under the .NET framework, used in 99% of .NET projects. Think of .NET as the ecosystem and C# as the language you write inside it.

What is the C# .NET Foundation Builder skill?

It is a structured learning framework that takes you from complete beginner to writing, compiling, and running real C# programs. It covers .NET platform context, environment setup, mandatory program structure, variables and data types, boxing/unboxing, and the method-per-task pattern for object-oriented architecture. Its defining principle is practicals over theory — every concept must be coded, compiled, and executed.

How do I compile and run a C# program without Visual Studio?

Write your code in Notepad with a .cs extension, set the PATH to the .NET framework directory (C:\Windows\Microsoft.NET\Framework\v4.x), then compile using 'csc filename.cs' in Command Prompt. This produces a .exe you run directly. Doing this once reveals the CIL → CLR → OS pipeline that Visual Studio hides behind its build button.

How do I structure a C# program correctly?

Every C# program requires: (1) 'using System;' to import the System namespace, (2) a namespace (logical container, capitalised), (3) a class to hold methods, and (4) 'public static void Main(string[] args)' — the fixed entry point. Use Console.WriteLine() to print. Keep Main for calling methods only; place all logic in separate, well-named classes.

When should I use static versus non-static methods in C#?

Use non-static (instance) components in 99% of real programs — they require an object created with 'new' and allocate memory at runtime. Use static components only when you deliberately want shared, compile-time memory called via the class name directly. Static methods are called via ClassName.Method(); instance methods require ClassName obj = new ClassName(); obj.Method().

How does this C# framework compare to just watching tutorials?

Tutorials deliver theory you passively consume; this framework enforces practicals over theory — every concept is coded, compiled, and executed with assigned practice programs. It also teaches the method-per-task pattern and the CIL → CLR → OS pipeline explicitly, so you understand what Visual Studio does behind the scenes rather than just clicking a play button.

What is boxing and unboxing in C#?

Boxing converts a value type (int, float, char) into a reference type (object) — an implicit conversion, e.g., 'object o = a;'. Unboxing converts the object back to a value type via explicit casting, e.g., 'int x = (int)o;'. Use them only when the data type is genuinely unknown at design time; otherwise prefer typed variables.

Why won't my C# method work when I call it from another class?

Methods are private by default, making them inaccessible outside their class. Always explicitly set an access modifier: 'internal' for access across the same project, or 'public' for access across projects. In Visual Studio, private methods appear greyed-out. Change the modifier to internal or public and the call will resolve.

What should I put in the Program.cs Main method?

Only method calls. Program.cs Main is exclusively for invoking methods — create an object of your logic class (ClassName obj = new ClassName();) and call its methods (obj.MethodName();). Never place arithmetic, input handling, or business logic directly in Main. All logic belongs in separate, well-named classes and methods for reusability and maintainability.

What results can I expect after using this C# foundation framework?

You will be able to set up Visual Studio, understand the .NET platform and compilation pipeline, write structurally correct C# programs, use variables, constants, literals, and data types confidently, apply boxing/unboxing, and build real programs (calculator, simple interest, number swaps) using the method-per-task pattern. You'll have a maintainable, object-oriented foundation ready for web, mobile, API, or desktop paths.

Do I need Visual Studio Code or Visual Studio for C#?

Use Visual Studio 2022 Community Edition (free) for C# and .NET back-end development — it is a full IDE for creating, compiling, debugging, and deploying .NET applications. Visual Studio Code is a lightweight front-end editor and a completely different tool. Do not conflate the two; they serve different purposes.

How do I read user input in a C# console app?

Use Console.ReadLine(), which always returns a string. To assign it to a typed variable, convert it with the Convert class: Convert.ToInt32(Console.ReadLine()) for integers, Convert.ToDouble() for doubles. Best practice is to accept input inside a dedicated method (e.g., void Accept()) and call it before your calculation method.

// GET THIS SKILL — FREE

Use this skill in your AI

Every skill on SkillForge is free. Drop your email and copy this skill straight into Claude, ChatGPT, or any LLM.

We'll email you when new skills drop. Unsubscribe anytime.