Line Saving Code Tricks – C#

Stuart's Pixel Games

Introduction

Reducing lines of code can make your work more readable, making it easier for you and for others to read. More lines means more mental gymnastics to decipher which part of code does what. I want to go over some tips and tricks that helpd me.

This is a guide I’ll update periodically if I discover new line saving tricks. If you know one that I haven’t put in, post a comment below to let me know and it may end up in the guide!

Smart Booleans

A real line saving trick is being smart with booleans. Below is a typical scenario you might have with turning off an objects animator once a counter has finished counting down.

void Update()
{
    counter--;
    
    if(counter > 0)
    {
        animator.enabled = true;
    }
    else  …

View original post 1,696 more words

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: