Category Archives: C#

Generating a random color in C#

Always wanted to have your own random color generator in C#? This snippet shows you how to do it.

Posted in C# | 1 Comment

Framerate GameComponent to calculate the frame rate (XNA Framework)

Microsoft XNA can be used to develop computer games. This code snippet contains a so called GameComponent written in C#. The GameComponent is called Framerate and it simply calculates the frame rate of the game at each Update cycle.

Posted in C# | Leave a comment

Properties in C#

Properties in C# can be used to set or get the value of an attribute. Suppose you have a class called Person which has the attributes name and age. class Person { String name; int age; public Person(String name, int age){ this.name = name; this.age = age; } } The attributes of the Person class [...]

Posted in C# | Leave a comment

Printing to the console in C#

The Console.WriteLine method can be used to print a line to the console. public void Foo(){ Console.WriteLine("Bar"); } //

Posted in C# | Leave a comment
  • Advertisement

  • Categories