C# Beginners Series Part 2 | Switch Statements

Did You Find This Easy To Understand?


  • Total voters
    4

Syndicate

Modder
Messages
671
Reaction score
551
Points
908
Decided to write this part tonight as i wont be able to release another Part for a few days.

*Please also note, most code in this series will be written as im writing the thread, its unlikely but if by some chance i do mess up in the code, please leave a comment below. Remember this series is targeted for beginners, there may be points in the series where i could of coded something more efficiently, however im trying to make it easy for a noob to understand!!*

In this part you SHOULD learn how switch statements work and how you can use them!


PHP:
        static void Main(string[] args)
        {
            Console.Write("Rate Syndicate Out Of 10!!");
            int marks = int.Parse(Console.ReadLine());

            switch (marks)
            {
                case 10: // if 10 is entered, execute next code!
                    Console.Write("Thank You");
                    break; // if conditions arent met, break  | jump to next

                default: // if all is false and a valid value hasent been entered
                    Console.Write("Your a **** bruhhh");
                    break;               
            }
            Console.Read();
        }
    }
}

Of course you can have more Case's look below for another example;


PHP:
static void Main(string[] args)
        {
            Console.Write("Please Type A Number!");
            int marks = int.Parse(Console.ReadLine());

            switch (marks)
            {
                case 10: // if 10 is entered, execute next code!
                    Console.Write("You Typed 10!");
                    break; // if conditions arent met, break  | jump to next

                case 9: // if 9 is entered, execute next code!
                    Console.Write("You Typed 9");
                    break; // if conditions arent met, break  | jump to next

                case 8: // if 8 is entered, execute next code!
                    Console.Write("You Typed 8");
                    break; // if conditions arent met, break  | jump to next

                default: // if all is false and a valid value hasent been entered
                    Console.Write("You didnt type 10, 9 or 8");
                    break;               
            }
            Console.Read();
        }

To all readers, i spend time to write this so if you do go to publish my code on another forum, please credit or just write the thing yourself!

Need Any Help? Skype- FourSeasonModz
 

swoon

Entrepreneur
Premium Member
Messages
490
Reaction score
353
Points
698
Maybe I should do c++ for advanced or people who understand a C language xD
 

swoon

Entrepreneur
Premium Member
Messages
490
Reaction score
353
Points
698
would be cool to have a section for C# and C++
Yes. However one small thread won't be able to teach them. Ill make them learn a **** ton of vocabulary, how to solve binary and convert stuff into a hexadecimal etc lel
 

Harry

Certified Sick ℂunt
Premium Member
Messages
1,263
Reaction score
969
Points
973
You should try this type of tutorial next time (Not at all having a go at this, I just wanna see it done more)
Put little parts of the code all over the thread, so they have to learn it and not just copy+paste the code.

Such as:
Code[]
What its about and why you need it
Code{}
What its about and why you need it
More Code []
Why that is needed to make Code[] work
More Code{}
Why that is needed to make Code{} work

If that isn't very 'understandable', just PM me :grinning:
 

Syndicate

Modder
Messages
671
Reaction score
551
Points
908
syntax is basic, if they haven't spent time to learn it then they cant be that bothered to learn C#
 

swoon

Entrepreneur
Premium Member
Messages
490
Reaction score
353
Points
698
syntax is basic, if they haven't spent time to learn it then they cant be that bothered to learn C#
You're wrong. C# is fairly easy, very similar to VB.net just different syntaxes almost. Anyways, C# is easily learned. Just how well you dedicate yourself.
 

Matt

Web Developer
Messages
245
Reaction score
215
Points
828
Yes. However one small thread won't be able to teach them. Ill make them learn a **** ton of vocabulary, how to solve binary and convert stuff into a hexadecimal etc lel

Is converting to hexadecimal supposed to be hard?
Note, I remember getting taught this one time in a Computer science lesson 3 years ago.
11010111
Separate your byte in to nybbles
1101/0111
Convert your nybbles in to denary using the beginning of Binary to Denary

8421/8421
1101/0111
13. - 6
Convert in to hexadecimal (0-9 a-f)
C6 (if this is wrong excuse me, its 2:30am)

If you want to flex your ePenis even harder, you could convert Denary to Hex and back again, but thats for another day
 
Last edited:

Encryption

Co-Leader of SM|T
Messages
27
Reaction score
12
Points
3
Is converting to hexadecimal supposed to be hard?
Note, I remember getting taught this one time in a Computer science lesson 3 years ago.
11010111
Separate your byte in to nybbles
1101/0111
Convert your nybbles in to denary using the beginning of Binary to Denary

8421/8421
1101/0111
13. - 6
Convert in to hexadecimal (0-9 a-f)
C6 (if this is wrong excuse me, its 2:30am)

If you want to flex your ePenis even harder, you could convert Denary to Hex and back again, but thats for another day
dec to hex is ezz af.
 

swoon

Entrepreneur
Premium Member
Messages
490
Reaction score
353
Points
698
the syntax is easy... how can I be wrong about a opinion related question?
You make it sound like they can't learn C#. The best way to learn is learning while you do it. Coding wise, also books are very helpful too. I can post some eBooks if you guys want.
 
Top