Posts Tagged class

Using Structs to Avoid Creating Garbage

Tags: , , ,

It’s easy to forget about struct in C#. After all, it’s not available in other languages like Java or AS3 and it seems to have fewer features than good old class. But struct can really help you out when it comes to garbage creation! Today’s article discusses some strategies to get the most out of struct. Read on to learn how to use structs to put a stop to that pesky garbage collector!

Read the rest of this article »

8 Comments

How to Recover Anonymous Types

Tags: , , , ,

When we just need a quick and dirty type to hold some values, C#’s anonymous types fit the bill: var person = { First="John", Last="Doe", Age=42 }. On the down side, since these types are anonymous they have no explicit type. The var variable is strongly typed, but you have to use the object type when passing them to other functions. But then how do you get the fields back out? Today’s article shows you how so that anonymous types will be more useful to you. Read on to find out how to recover anonymous types!

Read the rest of this article »

No Comments

From AS3 to C#, Part 13: Where Everything Goes

Tags: , , , ,

Today we continue the series by wrapping up C#’s class/interface/struct/enum system with a discussion of where to put them all. We’ll focus on package/namespace, organizing types into files, and some details of using/import.

Read the rest of this article »

2 Comments

From AS3 to C#, Part 11: Generic Classes, Interfaces, Methods, and Delegates

Tags: , , , ,

Continuing once again, today we cover an exciting new topic: generics! Have you ever wished your classes could be parameterized with a type like Vector.<Type> is? With C# generics, you can! Even better, you can parameterize your interfaces, methods, and delegates too. Read on to learn how.

Read the rest of this article »

12 Comments

From AS3 to C#, Part 5: Static Classes, Destructors, and Constructor Tricks

Tags: , , ,

Last week’s article mostly covered abstract classes, but this week we’ll discuss an even more abstract type of class: static classes. We’ll also explore C#’s anti-constructor, known as a destructor, and some fancy ways to construct a class. Read on and learn some more class-related features that were never available to us in AS3.

Read the rest of this article »

9 Comments

From AS3 to C#, Part 4: Abstract Classes and Functions

Tags: , , , , ,

Continuing from last time, this article begins covering features of C# classes that aren’t in AS3. We’ll begin with abstract classes and functions, which AS3 required workaround code to enforce even at run-time. Today’s article shows you how to use C# to cleanly enforce these at compile-time.

Read the rest of this article »

12 Comments

From AS3 to C#, Part 3: AS3 Class Parity

Tags: , , , , , , ,

Picking up from last time, today we’ll finish off classes in C# from an AS3 perspective in preparation for next week when we delve into all-new concepts that aren’t in AS3 at all. Read on to learn the C# way to implement getters and setters, final functions and classes, const variables, and packages.

Read the rest of this article »

13 Comments

From AS3 to C#, Part 2: Extending Classes and Implementing Interfaces

Tags: , ,

Let’s continue the From AS3 to C# series from last time by continuing to investigate C# classes from an AS3 developer’s point of view. Today’s article will cover class inheritance, interface implementing, and interface inheritance.

Read the rest of this article »

15 Comments

From AS3 to C#, Part 1: Class Basics

Tags: , ,

This article is for the AS3 developer who’s decided to switch to Unity and doesn’t know the first thing about programming in C#. It’ll walk you through the basics of C# to get you oriented and productive.

Read the rest of this article »

16 Comments

Making describeTypeJSON 50x Faster than describeType

Tags: , , , , , , , , , , ,

The hidden describeTypeJSON function is faster than the XML-based describeType function by default, but we can make it even faster. Today’s article describe just how this is done and achieves a nearly 10x speedup!

Read the rest of this article »

1 Comment