Kinetic Code Camp - Bring your skills, or lack thereof.. :dumpster_fire:

What is a Type?

According to Wikipedia:

In computer programming, a type system is a logical system comprising a set of rules that assigns a property called a type (for example, integer, floating point, string) to every term (a word, phrase, or other set of symbols). Usually the terms are various language constructs of a computer program, such as variables, expressions, functions, or modules.[1] A type system dictates the operations that can be performed on a term. For variables, the type system determines the allowed values of that term

That’s about as clear as mud isn’t it? festival mud GIF by Mitteldeutscher Rundfunk

Ok, English time, with examples.

Assuming you’ve read the section on variables, let’s proceed.


//[Type] [Variable Name] [Operator] [Value]
//The value of this variable is of Type "string" (text)
string donnaSummer = "She works hard for the money.";

//[Type] [Variable Name] [Operator] [Value]
//The value of this variable is of Type "int" (Integer)
int hitchhiker = 42;

ds


//Here is a function
//[Access Modifier] [Return Type] [Function(Method) Name] [ Input Parameters ([Type] [Variable Name]) ]
//You'll see two types in the signature, Return Type is bool (Boolean {true/false}), and the Input Parameters takes a string (text)
private bool AreYouRidiculous(string message)
{
    //Variable
    //[Type] [Variable Name] [Operator] [Value]
    bool output = true;

    //Something we do
    //Console WriteLine is a method that takes a TYPE of string (There are exceptions, they are not relevant here.)
    //[Method]( Input Parameters [Type -> string])
    Console.WriteLine(message);

    //This is a function, so we must have a return
    //This function must return a bool (Boolean)
    //We defined the "output" variable earlier as Type "bool", so we are good.
    //Return [Type]
    return output;
}

Types are not only simple types, like strings or numbers. They can also be objects, and depending on language, other constructs.

    //[Type] [Variable Name] [Operator] [Keyword] [Type]( [Constructor Values] )
    //This Type is an "object", specifically, an object of Type "DataTable".
    DataTable dt = new DataTable("MyCollectionOfPeopleToAnnoy");


    //This is a class object. It is an object. It is also a Type, called "Groot"!
    //[Access Modifier] [objectType: class][Name & Type]
    public class Groot
    {
        // [Type] [Special Keyword] [Variable Name] [Operator] [Value]
        // The "Special Keyword" here, "const", just makes this value immutable,
        // which means it cannot be changed... it is a "constant" by definition. This is set at compile time. 
        private const string speech = "I am Groot.";

        //[Access Modifier] [Return Type] [Function(Method) Name] [Input Parameters]
        public void Speak()
        {
            //[Method]( Input Parameters [Type -> string])
            Console.WriteLine(speech);
        }
    }


Different languages have differing Type “Systems”, but as for C#, here is a table that explains some of the “Base” Types.

Type Description Value
byte 8-bit unsigned integer 0 to 255
sbyte 8-bit signed integer -128 to 127
short 16-bit signed integer -32,768 to 32,767
ushort 16-bit unsigned integer 0 to 65,535
int 32-bit signed integer -2,147,483,648 to 2,147,483,647
uint 32-bit unsigned integer 0 to 4,294,967,295
long 64-bit signed integer -9,223,372,036,854,770,000 to 9,223,372,036,854,770,000
ulong 64-bit unsigned integer 0 to 18,446,744,073,709,551,615
float 32-bit Single-precision floating point type -3.402823e38 to 3.402823e38
double 64-bit double-precision floating point type -1.79769313486232e308 to 1.79769313486232e308
decimal 128-bit decimal type for financial and monetary calculations (+ or -)1.0 x 10e-28 to 7.9 x 10e28
char 16-bit single Unicode character Any valid character, e.g. a,*, \x0058 (hex), or\u0058 (Unicode)
bool 8-bit logical true/false value True or False
object Base type of all other types.
string A sequence of Unicode characters
DateTime Represents date and time 0:00:00am 1/1/01 to 11:59:59pm 12/31/9999

Season 3 Monday GIF by The Sinner

I hope this helps, I’m sure it can be expanded.. (by someone :rofl: )