You are on page 1of 11

THIS BOOK IS BY DARKNESS AND DAB OF THEBOTNET.

COM

THIS IS A PREVIEW COPY OF THE FULL EBOOK TO COME.









THEBOTNET BOOK OF CODING (C#)
BY DAB/DARKNESS

THIS BOOK IS BY DARKNESS AND DAB OF THEBOTNET.COM

THIS IS A PREVIEW COPY OF THE FULL EBOOK TO COME.





BOOK 1: THE BASICS




















THIS BOOK IS BY DARKNESS AND DAB OF THEBOTNET.COM

THIS IS A PREVIEW COPY OF THE FULL EBOOK TO COME.
Table of Contents
Introduction
What is programming
Why is it important?
Objectives
Requirements (IDE/Compiler, FireFox + toys, Want to learn,etc)
Chapter 1 (Introduction to C#): Hello World
Objectives: Get familiar to tools, learn flow of program
Important Terms/Ideas: Functions, Parameter, void, initialize,
How to Code (Extend on itself as well. Return types )
Conclusion: Code, newly learned things
Chapter 2 (Essentials): Variables, Loops, String Manipulation, Other Variable Types
Objectives: Learn About all variable types, scope, limits
Important Terms/Ideas: Concatenate, CharVsStr, Scope, Limit, Allocation
Codez (String manipulation, other things, array (textbox new lines))
Chapters Task: Create a bot that calculates fahrenheit to celsius


Introduction to C#
Hello there. If youre reading this, youre probably a member of TBN who wants to learn a bit of
coding. This book is meant for those who have the will to understand their code. Before we
move on to things like Threading (Ch. 5) or Regular Expressions (Ch. 7), well have to figure out
a few things.
What is Programming?
Well, programming is really creating an application. This programming is written in a certain
way. The style of how to write the code is based on the Programming Language used. In this
book, well be designing, writing, testing, debugging /troubleshooting, and maintaining the
source code of an Application (More specifically a Bot) in C#. For those of you with previous
coding experience, youll know that C# is very similar to VB.NET. Though there are major
differences present as well. C# is known to be superior to VB.NET due to its syntax and its
object-oriented code.
Why is it Important?
Programming is important for us to learn in order to automate tasks. How will we automate
tasks? Simple. We use the skills that weve learned from programming and put it into action.
Whether it be mass sign-ups or a link visitor, youll be able to bot it so you can live your life too.
Objectives
THIS BOOK IS BY DARKNESS AND DAB OF THEBOTNET.COM

THIS IS A PREVIEW COPY OF THE FULL EBOOK TO COME.
In order to reach a big goal, well have to take small steps. I want you to decide your objective.
Do you want to create a bot for Lockerz? Whatever you decide to bot, the journey to
successfully botting it, is a long journey. Well take small steps toward each aspect that youll
need to make that bot. Those small steps will have their own secondary objectives. As we take
these 11 small steps, well complete these secondary objectives for each step.

Requirements
In order to begin coding in C#, we must first acquire a few things from the internet. We need
something called an IDE. An Integrated Development Environment is what is going to compile
our code. The IDE we are going to use is called Visual Studio 2010. You may use an express
edition, it is recommended to buy a professional edition. Another requirement is Google
Chrome. Well be using Chrome for its, inspect element feature. Last, well need you to have
the time and the will to code regularly. If you do not read/code often enough you will lose the
habit and will ultimately lose the knowledge. Only continue if you agree to read/code
regularly.


Chapter 1 (Hello World)
Finally! Well be coding our first ever application! Im sure many of you have heard of Hello
World. For those who havent, Hello World is the universal term used by tutorials to help
starters. Well be creating a WindowsFormsApplication that will display a MessageBox saying
Hello World.
Objectives
The objectives of this chapter are to successfully use Voids to display Hello World. By doing
this well be introduced to the GUI of Visual Studio. Before we move on to out important ideas,
I think we should take a look at how our bot is going to function. If you dont understand the
following; dont be sad as youll understand after reading the chapter. The bot will start up and
THIS BOOK IS BY DARKNESS AND DAB OF THEBOTNET.COM

THIS IS A PREVIEW COPY OF THE FULL EBOOK TO COME.
show a button. If the button is clicked, a void will be initiated with a parameter string of Hello
World! The void will carry the function of displaying a MessageBox. The messagebox will
display the parameter. After the MessageBox is displayed the user may exit the application.
Important Ideas
Above we mentioned a few things. Before I explain to you what these terms mean, you should
know that theyre the fundamentals of C#. If you dont understand these terms, you will not be
able to code a bot. Also, for those coders with previous experience, we will not be using timers
to make functions. I repeat, WE WILL NOT BE USING TIMERS AS FUNCTIONS. Ill explain later
on why we wont be using timers. Anyways, I mentioned something called a void. In C# a void is
a block of code that doesnt return something, rather it does something. A block of code that
does return something can be a string (for words) or int (for numbers). Now lets challenge
yourself; well play true or false.
The following block of code is a string. True or False?



If you said false, youre correct! Why? Simply because the block of code returns 1 + 1. Lets try
this one. The following block of code is a void. True or False?



Indeed, its true! Although a string is declared, nothing is returned and instead something is
done with the string. Now that we understand voids a little better, lets move on. What is a
Parameter? A parameter is a string, integer, object, or any of the sorts that is used by the void.
Lets take a previous example.



That block of code can be changed by its parameter. In this case the parameter trait changes
what the string darkness means. We can call this void and its parameter by using:

{
int calculation;
calculation = 1 + 1;
return calculation;
}

{
String darkness;
darkness = "Mr. Coolguy";
textBox1.Text = darkness;
}

public void bob(string trait)
{
string darkness;
darkness = trait;
textBox1.Text = darkness;
}

bob("awesome");

THIS BOOK IS BY DARKNESS AND DAB OF THEBOTNET.COM

THIS IS A PREVIEW COPY OF THE FULL EBOOK TO COME.
That would call the void and tell the parameter trait to be awesome. It should be noticed
that after every complete statement there is a ;. Keep in mind that if a statement goes to a
second line the ; will be located at the end of the second line and not the first.
How to Code
Well not that you know about voids and parameters, its time to put that knowledge to use!
Open up Visual C# 2010. After it loads click on File, and then New Project. Name the project
Hello World.

After pressing OK. You should see an application. This is actually called a form and is used to
design the application. Click on the form once and press F7. There youll see some code:









using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Hello_World
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

THIS BOOK IS BY DARKNESS AND DAB OF THEBOTNET.COM

THIS IS A PREVIEW COPY OF THE FULL EBOOK TO COME.
Currently, we have a namespace(Pretty much just identifies the name of the project. This is the
largest block of code as it contains classes and voids), a class(the block of code that holds
smaller block of codes such as voids. Classes can be called but well learn about that later), and
a public Form1 (Starts up the form). Before adding any code it should be noted that all code will
go inside the class and not inside the public Form1. This is because public Form1 initializes the
form but does not run it. The class Form1 runs the form. Anyways, press Shift+F7 to get back to
the form. On your left you should see something entitled toolbox. Click on it. From there well
need to find a button( ) and drag it anywhere on the form. Once youve done this,
double-click on the button. You should now see this:


This particular void specifies what to do if button1(Our Button) is clicked. In between the {
and }(the things that specify where a block of code starts and ends), put helloWorld(Hello
World); . Dont mind the errors for now. Now well create a private void called helloWorld.
Since were going to have a parameter that is a string the whole name should be private void
helloWorld(string hello). Now well add { and } with 1 line to space them apart. You should
now have this:


Now well add one line of code that will show the messagebox. But first lets discuss something.
A MessageBox is an object. To show this type of object we use .Show(); . But this wont work.
Why? Because MessageBox.Show has parameters as well. In this case the parameter is the text
to be displayed. The code for the void is:



It should be noted that the green text is called a comment. Comments are started with double
/s. They are for explaining code. Since weve already added the code to call helloWorld, you
can go ahead and press F5 to get your program running. The final code should be:


private void button1_Click(object sender, EventArgs e)
{

}

private void helloWorld(string hello)
{

}

private void helloWorld(string hello)
{
MessageBox.Show(hello);
/ / Shows t he par amet er hel l o t o user s vi a MessageBox
}

THIS BOOK IS BY DARKNESS AND DAB OF THEBOTNET.COM

THIS IS A PREVIEW COPY OF THE FULL EBOOK TO COME.

















Chapter 2 (Essentials)
This chapter focuses on variables and objects as they are required to code. Variables are a way
to store data. Variables can hold words, numbers, pictures, and a whole lot more. Chapter 2
will be split into sub-categories. Each will have objectives, important ideas, and code.
Integrals
Integrals are the type of variables that hold whole numbers; integers. They come in different
types based on your number range and use.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Hello_World
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void helloWorld(string hello)
{
MessageBox.Show(hello);
// Shows t he par amet er hel l o t o user s vi a MessageBox
}

private void button1_Click(object sender, EventArgs e)
{
helloWorld("Hello World");
// Calls private void helloWorld with parameter as
// "Hello World".

}
}
}


THIS BOOK IS BY DARKNESS AND DAB OF THEBOTNET.COM

THIS IS A PREVIEW COPY OF THE FULL EBOOK TO COME.
Objectives
The objectives of this sub-chapter are to be able to correctly use integral variables to hold
integers. You should know when to use decimal types and when to use integral types.
Important Ideas
This mini-chapter has the most terms to remember than any other mini-chapter or full chapter.
That is why we will only introduce the most common integral variables. These include int, byte,
long, and char, though we will encounter more later on. Another important idea is that of bits.
[NEED MORE INFORMATION]
How to Code
Heres chart featuring the main integral variables.
Type Size (in bits) Range
sbyte 8 -128 to 127
byte 8 0 to 255
int 32 -2147483648 to 2147483647
uint 32 0 to 4294967295
long 64 -9223372036854775808 to 9223372036854775807
ulong 64 0 to 18446744073709551615
char 16 0 to 65535

The most common type is int. The amount of bits means how much processing it will take to
read that variable. Though even though int is most common, you should base which type to use
based on your number. If you are unsure on the number pick int. Notice that uint and ulong are
only positive numbers but they have the same range as their normal counterparts.
Strings
A string in C# is just a sequence of letters. Strings are almost always in quotes. Strings are used
very often. In fact in our first chapter output a string with a messagebox. The string was Hello
World.
Objectives
The objectives of this mini-chapter are to understand escape sequences and literals. We will
play true or false to differentiate what a string will output as.
Important Ideas
THIS BOOK IS BY DARKNESS AND DAB OF THEBOTNET.COM

THIS IS A PREVIEW COPY OF THE FULL EBOOK TO COME.
This chapter has almost as many terms as integral variables. First, however, we need to
understand what an escape sequence is. In C# and other languages, there is syntax to represent
non-printable characters. A backslash like so \ is used to escape. That means that the following
letter wont print out \n for example. It will print out a new line. Take a look at this chart.
Escape Sequence Meaning
\' Single Quote
\" Double Quote
\\ Backslash
\n Newline
These are not the only escape sequences. However, they are the only ones that I will ever use in
this book. For a full chart please check the Extras section. Alright, now lets play true or false.

This string outputs I like Pie
Yay. True or False.


If you said false you are correct. The above will output I like pie /n yay because the escape
character was not used.
This string outputs I am Darkness \n


TRUE. The reason for this is due to something called a literal. A literal makes a string, as its
name suggests, literal. So \n outputs as \n and not a new line.



Boolean
Boolean variables are limited to two possible meanings. They can be true. Or they can be false.
Booleans can come in very handy later on in the book. For now well leave it to Booleans being
true or false.
Objectives
The objectives of this mini-chapter are to know what Booleans are and how they are often
used.
Important Ideas
String sExample = "I like pie /n yay";







String sExample = @"I am Darkness \n";







THIS BOOK IS BY DARKNESS AND DAB OF THEBOTNET.COM

THIS IS A PREVIEW COPY OF THE FULL EBOOK TO COME.
Something we need to grasp is the fact that Booleans are declared with just one = rather than
usual ==. This is because = assigns things. When you have == it compares something. For
example,
String bob = cool assigns bob to cool. However, string bob == cool compares bob to cool
resulting in an error as that does not do anything.
How to Code
This is a quick example of how Booleans can be used.













The above outputs It is true that Darkness is very cool. The above statement is false.


using System;

class Booleans
{
public static void Main()
{
bool content = true;
bool noContent = false;

Console.WriteLine("It is {0} that Darkness is very cool", content);
Console.WriteLine("The statement above is {0}", noContent);
}
}

You might also like