Header Banner
Null Byte Logo
Null Byte
wonderhowto.mark.png
Cyber Weapons Lab Forum Metasploit Basics Facebook Hacks Password Cracking Top Wi-Fi Adapters Wi-Fi Hacking Linux Basics Mr. Robot Hacks Hack Like a Pro Forensics Recon Social Engineering Networking Basics Antivirus Evasion Spy Tactics MitM Advice from a Hacker

How to Program in C# : Variables and Data Types (Part 2)

C# programming language logo with a digital background.

Welcome back my friends !!

Today we'll go through the second part of this C# series

Let's start!!

Last time we left off with Console.WriteLine and Console.ReadKey now we'll combine these with some variables and comments.

Comments are useful for multiple reasons: for exemple they can help other developpers read your code or help you in case you

forgot what a line does or things like those.

Speaking of variables ...these are the 3 main data types of variables

(we'll see the rest of them as we procede into this series):

(EXEMPLES ARE DOWN THE LIST)

  • int (integers) : This variable defines only non-decimal numbers (like 1, 3, 4, 5, 259, 4000 etc...).
  • var : this is an implicit way of defining data types , unlike int or string (meaning ...in a indirect way or "generic" if you wish).
  • string : this variable only accepts text.

Here's an exemple of all 3 of them:(you may want to zoom in with your browser since it's quite small but everything's commented)

Code snippet demonstrating variable declaration and output in a programming environment.

!!!!WARNING!!!!

always remember the " ; "(it's called "semi-colon") symbol at the end of the variables declaration line.

(There's a semi-colon at the end of every expression statement

and declaration statement, so you MUST NOT put the semi-colon at the end of every line)*

So...All types of variables can be "entered" or defined in 2 ways:

1) The first by first declaring the data type and then assign a value to the variable like this:

int x;

x = 2;

2) The second by declaring the data type and assigning the variable a value on the same line like this:

int x = 2;

Both of them are right.

That's all for now.

Thank you for reading

ThE-F1XeR

Apple's iOS 26 and iPadOS 26 updates are packed with new features, and you can try them before almost everyone else. First, check Gadget Hacks' list of supported iPhone and iPad models, then follow the step-by-step guide to install the iOS/iPadOS 26 beta — no paid developer account required.

Related Articles

Comments

No Comments Exist

Be the first, drop a comment!