Hack Forums
[The Academy] Your first C# program - Padrino's Tutorials: Part 1 - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5)
+---- Thread: [The Academy] Your first C# program - Padrino's Tutorials: Part 1 (/showthread.php?tid=6300158)



Your first C# program - Padrino's Tutorials: Part 1 - padrino - Jun 12, 2025

Introduction
So this will be super trivial for a lot of people on here, but there are a lot of threads asking on how to get started in programming and software development. So I thought I'd do a few threads on the very basics you need to understand the basics of software development. We'll be using C# as our language, and Visual Studio Community Edition as our IDE (Integrated Development Environment).

Getting set up

You want to head over to Microsofts's Visual Studio site here, and download the latest version of community edition. On install, you're going to be prompted to customise your installation and choose what workloads you want. For now you want to choose 'ASP.NET and web development' and '.NET desktop development'. This will give you everything you need to build websites, windows forms, and console apps. You can go back and install any additional componants later as and when you need them (if you decide to do some python programming in the future, for instance).

[Image: Screenshot-2025-06-12-101501.png]

If you're struggling, Microsoft have a pretty decent guide here.

Creatng your first console app
Ok so, once everything is installed, you want to launch Visual studio and hit 'Create a new project' and choose 'Console app'.

[Image: Screenshot-2025-06-12-102427.png]

You should now be greeted with a screen with a line of code that says the following:

Code
Console.WriteLine("Hello, World!");

if you run that application by clicking the green 'play' button the top of the screen you should see that the app opens up your terminal and displays the message "Hello, World!". Congratulations, you just made and ran your first application!

Ok, lets do some real programming!
Ok, next, I want you to delete that line of code, and type this out in it's place.

Code
Console.WriteLine("Hello, what's your name?");
string name = Console.ReadLine();

Console.WriteLine("Hello, " + name + ", It's nice to meet you!");

Now, run that code and you will see that the console asks you your name, allows you to type a reply, and then integrates your input into it's response. Pretty neat huh?

So, how does this code work?
Well, believe it or not you actually just learnt some cool programming concepts without knowing it. Let's go over them line-by-line:

Code
Console.WriteLine("Hello, what's your name?");

This as you can probably guess, simply outputs whatever you put in the perenthesis to the console. It has to be enclosed in quotes like "this" as it has to be in the form of a string. What's a string? Think of it like written speech - it's something to be read or written.

Code
string name = Console.ReadLine();

Now, this is where we're starting to code properly. What does this line do? Well, let's break it down.

1) It creates a new variable of the type string and gives it a name that we can reference later. In this case, we called it name.

2) We then assign a value to that new variable using the '=' operator and by reading whatever the user inputs, with Console.ReadLine();.

Congratulations you've just created and used a string variable for the first time!

Code
Console.Write("Hello, " + name + ", It's nice to meet you!");

Ok, next we finally output a response to your input, but how did we do it? Well, we used Console.WriteLine(); again, just like we did for the first line, but this time we integrated your response into it using a technique called 'string concatenation'. Basically we took 2 strings of "Hello, " and "It's nice to meet you!" and inserted the users input inbetween them. In the previous step we already collected the user input and assigned it the variable name of 'name' so we just need to connect these strings together into one. We do this with the '+' opperator. So the final string looks like this: "Hello, " + name + ", It's nice to meet you!".

Conclusion

In this small tutprial, you have now got yourself a working development environment, you've learnt about the very basics of console apps, you've created and assigned values to a variable, and learnt about basic string opperations.

If you struggle to understand these concepts, don't worry, I'm going to be doing a bunch of tutorials breaking down the fundementals of programming. We'll go over everything you need to know again, and in greater detail so, if it doesn't make sense now, it will in the future. I hope this has given you a taste of programming and makes you want to try more. As I say I'll be writing a bunch more tutorials as the weeks go on, but if you have any questions in the meantime my DMs are always open!

Just noticed I've posted this in the wrong subforum.... meant to be coders lounge

Sorry! mods feel free to delete of move if needed.


RE: Your first C# program - Padrino's Tutorials: Part 1 - JoseMar - Jun 12, 2025

Great thread, padrino
Really glad to see members putting effort for the benefit of both users and the site. Keep up the awesome work, looking forward to more quality threads like this!
You’ve earned this: +12 from me, well deserved.


RE: Your first C# program - Padrino's Tutorials: Part 1 - padrino - Jun 12, 2025

(Jun 12, 2025 07:00 AM)JoseMar Wrote:  Great thread, padrino
Really glad to see members putting effort for the benefit of both users and the site. Keep up the awesome work, looking forward to more quality threads like this!
You’ve earned this: +12 from me, well deserved.

Thanks bro - much appreciated!

Also to anyone reading this thread, my apologies for the typos and spelling issues. I’m dyslexic so they sometimes escape me - I’m fixing them as I see them though!


RE: Your first C# program - Padrino's Tutorials: Part 1 - Bastille - Jun 13, 2025

Thanks for the share, can't wait to see the next ones

Few weeks ago I've started learning C but don't have enough time to continue, but programming is definitely something I want to dive into, it will hep me for malware analysis.

I saw many malware made with C# during my analysis, feel free to apply your tutorial to malware / malware analysis !


RE: Your first C# program - Padrino's Tutorials: Part 1 - g40g095495 - Jun 13, 2025

Thanks for this! C# I have always wanted to get into, and now thanks to you, I can begin


RE: Your first C# program - Padrino's Tutorials: Part 1 - padrino - Jun 13, 2025

(Jun 13, 2025 11:51 AM)g40g095495 Wrote:  Thanks for this! C# I have always wanted to get into, and now thanks to you, I can begin

You’re welcome mate - this is a very basic starting point but it will get you up and running. Keep an eye out for future tutorials, I’ll be releasing a new one going over variables and data types soon.

As always, my DMs are open if you have any coding questions. Providing you’re not coding anything illegal - I’ll always help in anyway I can.