Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › Programming Tutorials › [C#] Tutorial: Understanding Classes

[C#] Tutorial: Understanding Classes

Posts 1–10 of 10 · Page 1 of 1
richdude212
richdude212
[C#] Tutorial: Understanding Classes
Start a console app project and add this code inside the namespace



- Creating the class called Output
Code:
class Output
- Declaring two strings the will hold our text
Code:
        string myString;
        string nextString
- Creating a method called Output and declaring two new strings that will hold the text that will be outputted.
Code:
 public Output(string inputString, string input2String)
        {
            myString = inputString;
            nextString = input2String;
        }
- Creating the method that will allow us to print (we will call this later)
Code:
        public void print()
        {
            Console.WriteLine("{0} {1}", myString, nextString);
        }

So far you should look like this:
Code:
class Output
    {
        string myString;
        string nextString;

        
        public Output(string inputString, string input2String)
        {
            myString = inputString;
            nextString = input2String;
        }


        public void print()
        {
            Console.WriteLine("{0} {1}", myString, nextString);
        }


    }

Next add this:
Code:
class program
    {

        public static void Main() 
    {
        
        Output Out = new Output("First one", "Next one");

        
        Out.print(); 
        Console.Read();
    }
    }

Code:
Output Out = new Output("First one", "Next one");
This snippet is declaring the class Output as a new name, out. It is setting it equal to Output with two strings.

Code:
        Out.print(); 
        Console.Read();
Now we call our print function which will display "First one Next one" on the screen. console.Read(); just holds it on the screen.

Your finally code should look like this:
Code:
class Output
    {
        string myString;
        string nextString;

        // Constructor
        public Output(string inputString, string input2String)
        {
            myString = inputString;
            nextString = input2String;
        }


        public void print()
        {
            Console.WriteLine("{0} {1}", myString, nextString);
        }


    }


    class program
    {

        public static void Main() 
    {
        
        Output Out = new Output("First one", "Next one");

        
        Out.print(); 
        Console.Read();
    }
    }
If I was of any help press thanks, if you have any questions please post them.
#1 · 15y ago
Jason
Jason
Not very well explained really. No mention of what a constructor is or does (you just said make a method called Output..lol), sorta just copy and paste this and voila you have a class. More detail is needed because this is a fundamental in programming, it's necessary to explain it properly so people don't get the wrong impression at the very start of their programming career. My Java lecturer was explaining classes the other day and he did a good job (despite the fact that I nearly fell asleep with boredom) explaining all about instance variables, access modifiers, constructors, methods...etc. You need to actually go into some detail for this to count as a tutorial.
#2 · 15y ago
♪~ ᕕ(ᐛ)ᕗ
♪~ ᕕ(ᐛ)ᕗ
Quote Originally Posted by Jason View Post
Not very well explained really. No mention of what a constructor is or does (you just said make a method called Output..lol), sorta just copy and paste this and voila you have a class. More detail is needed because this is a fundamental in programming, it's necessary to explain it properly so people don't get the wrong impression at the very start of their programming career. My Java lecturer was explaining classes the other day and he did a good job (despite the fact that I nearly fell asleep with boredom) explaining all about instance variables, access modifiers, constructors, methods...etc. You need to actually go into some detail for this to count as a tutorial.
TBH, i didn't read all your post, but I think it's pretty much easy to understand what he said.....Really really easy.

ps:
make it:
Code:
public static void Main(string[] args)
{
      //BlaBla
}
Just a recomandation
#3 · edited 15y ago · 15y ago
Jason
Jason
Quote Originally Posted by Play&Win View Post


TBH, i didn't read all your post, but I think it's pretty much easy to understand what he said.....Really really easy.

ps:
make it:
Code:
public static void Main(string[] args)
{
      //BlaBla
}
Just a recomandation
You even know what you're talking about? .

If you actually bothered to read my post, I said classes were a <let me highlight the import parts for your selective reading>

FUNDAMENTAL ASPECT of learning to program, i.e you LEARN THEM AT THE BEGINNING WHEN YOU DON'T KNOW AN INT FROM A STRING so special attention must be given to ENSURE THE NEW PROGRAMMER UNDERSTANDS WHAT A CONSTRUCTOR IS, WHAT A METHOD IS, WHAT ACCESS MODIFIERS DO, HOW TO CONSTRUCT A NEW INSTANCE OF THE CLASS AND CALL IT'S METHODS.

Shit man, I didn't have any trouble understanding it either, but...oh wait... I already know how to program. Of course it's easy to understand if you know how to program, fuck sake.
#4 · edited 15y ago · 15y ago
♪~ ᕕ(ᐛ)ᕗ
♪~ ᕕ(ᐛ)ᕗ
Quote Originally Posted by Jason View Post


You even know what you're talking about? .

If you actually bothered to read my post, I said classes were a <let me highlight the import parts for your selective reading>

FUNDAMENTAL ASPECT of learning to program, i.e you LEARN THEM AT THE BEGINNING WHEN YOU DON'T KNOW AN INT FROM A STRING so special attention must be given to ENSURE THE NEW PROGRAMMER UNDERSTANDS WHAT A CONSTRUCTOR IS, WHAT A METHOD IS, WHAT ACCESS MODIFIERS DO, HOW TO CONSTRUCT A NEW INSTANCE OF THE CLASS AND CALL IT'S METHODS.

Shit man, I didn't have any trouble understanding it either, but...oh wait... I already know how to program. Of course it's easy to understand if you know how to program, fuck sake.
damn sorry if I made you mad. but I didn't say that you can't program..Ar nvm.Sorry again...
#5 · 15y ago
Jason
Jason
Quote Originally Posted by Play&Win View Post


damn sorry if I made you mad. but I didn't say that you can't program..Ar nvm.Sorry again...
I never said you did say that, I said it IS easy to understand...if you already know how to program. To beginners that actually need the tutorial, they won't get some of the concepts.
#6 · 15y ago
♪~ ᕕ(ᐛ)ᕗ
♪~ ᕕ(ᐛ)ᕗ
Quote Originally Posted by Jason View Post


I never said you did say that, I said it IS easy to understand...if you already know how to program. To beginners that actually need the tutorial, they won't get some of the concepts.
well now I understood. Well, yes you're right, he should explain what he said...Thanks, but the method that you said your previous post was like: WAW! .
#7 · 15y ago
Jason
Jason
Quote Originally Posted by Play&Win View Post


well now I understood. Well, yes you're right, he should explain what he said...Thanks, but the method that you said your previous post was like: WAW! .
[highlight=c#]
public Output(string inputString, string input2String)
{
myString = inputString;
nextString = input2String;
}
[/highlight]

How is a person with little prior programming experience going to know that this is a constructor?
#8 · 15y ago
GR
GrimDesire
O_O im still learning c++ sooo this needs to be explained a little more
#9 · 15y ago
MC²
MC²
thanks kinda helped
#10 · 15y ago
Posts 1–10 of 10 · Page 1 of 1

Post a Reply

Tags for this Thread

None