Skip to content

PolyCode

Tech & Game Dev Made Simple

Menu
  • POLYCODE
    • Projects & Devlogs
    • Tech & Game News
    • Dev Tools & Plugins
    • Game Development
    • Community & Interviews
    • Programming & Code
    • Game Design & Art
    • Upcoming Releases
  • Game Dev Tools
    • Popular Game Engines
      • Unity 3D
      • Unreal Engine
      • Godot Engine
      • GameMaker Studio
      • Construct 3
    • Development Tools
      • Visual Studio
      • Blender
  • Programming Languages
    • C#
    • C++
    • JavaScript
    • Java
    • Swift
    • Kotlin
    • GDScript
  • Gaming Platforms
    • PC Gaming
    • Console Gaming
    • Mobile Gaming
    • VR/AR Platforms
    • Cloud Gaming
  • Essential Game Elements
    • Audio Components
    • Visual Assets
    • Technical Elements
    • Game Design Components
    • Game Monetization Strategies
Menu
C# Program

C# Programming Basics

Posted on August 30, 2025August 30, 2025 by polycode.tech

C# (pronounced “C Sharp”) is a modern, object-oriented programming language developed by Microsoft. It’s widely used for building desktop apps, web apps, mobile apps, and games (especially with Unity).

Contents hide
1 1.Your First C# Program
1.1 Explanation:
2 2.Variables & Data Types
3 3.Operators
4 4.Control Flow
4.1 If-Else
5 5.Loops
5.1 For Loop
5.2 While Loop
6 6.Arrays
7 7.Methods (Functions)
8 8.Classes & Objects

1.Your First C# Program

A simple C# program looks like this:

using System;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Hello, World!");
    }
}

Explanation:

  • using System; → imports basic functionality (like Console for input/output).
  • class Program → defines a class (the building block of C# programs).
  • static void Main(string[] args) → the entry point of every C# application.
  • Console.WriteLine() → prints text to the screen.

2.Variables & Data Types

C# is strongly typed, meaning each variable has a specific data type.

int age = 25;             // Integer
double price = 19.99;     // Decimal numbers
char grade = 'A';         // Single character
string name = "Alice";    // Text
bool isStudent = true;    // True/False

3.Operators

int a = 10, b = 5;

Console.WriteLine(a + b); // 15 (addition)
Console.WriteLine(a - b); // 5  (subtraction)
Console.WriteLine(a * b); // 50 (multiplication)
Console.WriteLine(a / b); // 2  (division)
Console.WriteLine(a % b); // 0  (remainder)

4.Control Flow

If-Else

int age = 18;

if (age >= 18)
    Console.WriteLine("You are  an adult.");
else
    Console.WriteLine("You are a minor.");  
                                        

Switch

string day = "Monday";

switch (day)
{
    case "Monday":
        Console.WriteLine("Start of the week!");
        break;
    case "Friday":
        Console.WriteLine("Weekend is near!");
        break;
    default:
        Console.WriteLine("Another day.");
        break;
}

5.Loops

For Loop

for (int i = 1; i <= 5; i++)
{
    Console.WriteLine("Number: " + i);
}

While Loop

int count = 1;
while (count <= 5)
{
    Console.WriteLine("Count: " + count);
    count++;
}

6.Arrays

string[] fruits = { "Apple", "Banana", "Cherry" };

foreach (string fruit in fruits)
{
    Console.WriteLine(fruit);
}

7.Methods (Functions)

static int AddNumbers(int x, int y)
{
    return x + y;
}

Console.WriteLine(AddNumbers(5, 10)); // Output: 15

8.Classes & Objects

class Car
{
    public string Brand;
    public int Year;

    public void Start()
    {
        Console.WriteLine(Brand + " is starting!");
    }
}

// Using the class
Car myCar = new Car();
myCar.Brand = "Toyota";
myCar.Year = 2020;
myCar.Start(); // Toyota is starting!

Summary:

  • C# is object oriented and strongly typed.
  • Key concepts: variables, operators, control flow, loops, arrays, methods, and classes.
  • It’s powerful for games, apps, and enterprise software.

    Post Views: 90
    Category: C#, Csharp

    Post navigation

    ← What Is the Best Gaming Cloud
    3D Models by AI for Your Game: The Future of Game Development →

    3 thoughts on “C# Programming Basics”

    1. Nikolas Howe says:
      August 30, 2025 at 8:32 pm

      I loved as much as youll receive carried out right here The sketch is attractive your authored material stylish nonetheless you command get bought an nervousness over that you wish be delivering the following unwell unquestionably come more formerly again as exactly the same nearly a lot often inside case you shield this hike

    2. Violet Bergnaum says:
      August 30, 2025 at 9:54 pm

      Simply wish to say your article is as amazing The clearness in your post is just nice and i could assume youre an expert on this subject Well with your permission let me to grab your feed to keep updated with forthcoming post Thanks a million and please carry on the gratifying work

    3. Sid Dietrich says:
      August 31, 2025 at 8:56 am

      Thank you I have just been searching for information approximately this topic for a while and yours is the best I have found out so far However what in regards to the bottom line Are you certain concerning the supply

    Leave a Reply

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

      Is Construct 3 Completely Free? What Are the Limits of the Free Version?

      Is Construct 3 Completely Free? What Are the Limits of the Free Version?

      Construct 3 has become a popular choice for indie developers, educators, and…

      Is Construct 3 Subscription Based? How Can You Cancel It?

      Is Construct 3 Subscription Based? How Can You Cancel It?

      On: October 17, 2025
      In: Blog, Construct 3, Game Dev Tools, Popular Game Engines
      What Is Construct 3 Used For? Can You Sell Games Made with It(Construct 3 games)?

      What Is Construct 3 Used For? Can You Sell Games Made with It(Construct 3 games)?

      On: October 16, 2025
      In: Blog, Construct 3, Game Dev Tools, Popular Game Engines

      Most Viewed Posts

      • Complete Guide to Unreal Engine 5’s Nanite Technology: Graphics Revolution for Developers
      • The Complete Guide to Construct 3: Create Games Without Coding
      • Best Gaming PC Under $500: Budget Friendly Options
      • New VR Game Launch Dates: Your Ultimate 2025 Release Guide
      • 6 Best HTML Coding Games to Learn Coding
      • Is Construct 3 Completely Free? What Are the Limits of the Free Version?
      • Is Construct 3 Subscription Based? How Can You Cancel It?
      • What Is Construct 3 Used For? Can You Sell Games Made with It(Construct 3 games)?
      • Does Construct 3 Coding? What Programming Language Does It Use?
      • Is Construct 3 Beginner Friendly and Safe? What Are Its Pros and Cons?

      Most Viewed Posts

      • Complete Guide to Unreal Engine 5’s Nanite Technology: Graphics Revolution for Developers (287)
      • The Complete Guide to Construct 3: Create Games Without Coding (261)
      • Best Gaming PC Under $500: Budget Friendly Options (253)
      • New VR Game Launch Dates: Your Ultimate 2025 Release Guide (247)
      • 6 Best HTML Coding Games to Learn Coding (203)
      • DISCLAIMER
      • TERMS OF USE
      • PRIVACY POLICY
      • Home
      • About
      • Contact Us
      Poly Code
      © 2025 PolyCode | Powered by POLYCODE.TECH WordPress Theme