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).
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 (likeConsolefor 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.
Game Engine Architecture
In this new and improved third edition of the highly popular Game Engine Architecture,
Auto-Rig Pro
Auto-Rig Pro is an all-in-one solution to rig characters, retarget animations, and provide Fbx export, with presets for Unity and Unreal Engine. First developed as my own in-house rigging tool, i\'ve released it a few years ago and many new features have been added since then.
PolyCode Live Dev Insights
🔥 GitHub Trending Repositories
- anything_about_game ⭐ 3686
- HTFramework ⭐ 817
- PoiGalgame ⭐ 148
- GDX ⭐ 79
- Atomic ⭐ 79
❓ StackOverflow Questions
- How to restrict joint rotations in CCD
- Unity Material coming up as null from UIToolkit, and it won't set custom attributes
- Unity XR: Prevent grabbed objects from passing through each other (hard boundaries while grabbed)
- Crash unity app related to com.android.webview.chromium.WebViewChromium.c
- OnGUI label not staying centered above GameObject when viewed from different distances
Articles
- The Complete Guide to Unity3D Audio Components: What They Are and How to Use Them
- Unity Game Development A Complete Guide for Beginners and Professionals
- How to Create 7 Fun Secret Code Activities for Kids at Home
- Best Gaming PC Under $500: Budget Friendly Options
- The Ultimate Guide to Building a Successful Mobile Gaming Studio
Someone essentially help to make seriously posts I’d state. This is the very first time I frequented your website page and so far? I amazed with the research you made to make this particular submit amazing. Fantastic job!
Hi my friend! I want to say that this post is amazing, great written and include almost all vital infos. I would like to see extra posts like this .
Thank you a bunch for sharing this with all folks you really know what you’re speaking approximately! Bookmarked. Kindly additionally visit my web site =). We can have a hyperlink trade arrangement between us!
I was very pleased to find this web-site.I wanted to thanks for your time for this wonderful read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you blog post.
I was recommended this website via my cousin. I’m no longer certain whether this submit is written by him as nobody else understand such distinct approximately my difficulty. You’re wonderful! Thanks!
I don’t even know how I ended up here, but I thought this post was great. I don’t know who you are but certainly you’re going to a famous blogger if you are not already 😉 Cheers!
I enjoy your piece of work, appreciate it for all the good content.
I see something really interesting about your blog so I saved to my bookmarks.
Merely wanna state that this is very beneficial, Thanks for taking your time to write this.
The next time I read a blog, I hope that it doesnt disappoint me as much as this one. I mean, I know it was my choice to read, but I actually thought youd have something interesting to say. All I hear is a bunch of whining about something that you could fix if you werent too busy looking for attention.
This really answered my downside, thank you!
I think this internet site has some really superb information for everyone. “The foundation of every state is the education of its youth.” by Diogenes.
Just a smiling visitor here to share the love (:, btw outstanding design and style. “Competition is a painful thing, but it produces great results.” by Jerry Flint.
Pretty section of content. I just stumbled upon your weblog and in accession capital to assert that I acquire actually enjoyed account your blog posts. Any way I will be subscribing to your feeds and even I achievement you access consistently fast.