A beginner friendly breakdown of creating classes and objects in C#

What is a class?

A class is a blueprint for a data-type (data-types such as string, integer, Boolean .etc). By creating a class, you are creating your own data-type.

View the example of a class below, lets work through it.

class Box {   public double Length { get; set; }   public…


Variables

type variableName = assignedValue

int — numbers / integers without decimals

double — integers with decimals

char — single characters ‘A’ with single quotes

string — text, with double quotes:

  • string: .Length, .ToUpper, .ToLower, .Concat
  • string interpolation: don’t need to include spaces in the variable — $"My full name is…

Guess who’s back with the Anime x Coding examples!

OOP (object-oriented programming) is about creating objects that contain:

  • Data (variable defined directly in the class? => Field)
  • Methods (functions, block of code that runs only when called, can accept parameters)

OOP core concepts:

  • Encapsulation
  • Inheritance
  • Abstraction
  • Polymorphism

Methods

Methods in C# => name of method capitalised with parentheses the end. …


Beginner friendly: Sorting a string and then reversing it to return the highest possible int.

If we had the integer 1105198, we would want to sort it to 0111589, then reverse it in order to make the highest integer possible, which would be 9851110.

In JavaScript

  • Define your function with a parameter…


A breakdown of how to reverse an array of numbers using a for loop in JavaScript.

For loop diagram

Lets take the array: [11, 5, 19, 98]for example. We want the reverse: [98, 19, 5, 11]

1. Define the function and parameter for the array of numbers

function reverseArrayOfNumbers(arr){

*code body*

}

2. Create an empty array

This is to store the numbers in once they’ve been reversed

let reverseArray = [];

3. Create a for loop

for (let i = arr.length — 1 ; i >=0 ; i--){

*for…


Alexa, play “Do It” by Chloe x Halle.

Most people familiar with coding know about Python, either what it is or how it works. Someone who is new and wanting to learn how to code might even consider learning Python as their first language. Here’s my take on that:

Do…


Object-oriented programming

At the moment everyone’s favourite question for me seems to be:

‘Do you know what object oriented programming is?’

The first time I was asked, I didn’t know. The second time I was asked, I knew slightly, but that wasn’t good enough for me. The next person to ask me…


Over the last few months, I’ve built up a stock pile of coding articles that I want to read. Sometimes I scroll past interesting articles on LinkedIn, or Medium sends me great suggestions through newsletters. I always open the articles and say, “I’ll read them soon”.

Well today is the…


Finding a Balance between Comfort and Coding

If we weren’t in the middle of a pandemic this article would probably consist of ‘sit in your local coffee shop! Sip and relax as you code!’ with flower and sparkle emoji’s. You know the ones.

If you’re like me, my only environments…


If you’ve got buttons that look uneven, differing heights and a bit messy, like this:

But you want them to all be perfectly aligned, like this:

Olivia Walker

Hi, I’m Olivia and I’m currently learning how to code. It’s challenging and fun. Join me as I blog about the highs and lows.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store