# Programavimas

## Makefile example

Some time ago I created my first Makefile. Now I have an Embedded Linux lecture. And the first task is to create a Makefile for the program.

## C#. Int array vs. ArrayList vs. Dictionary

private static void TestIntArray() { int [] array = new int[1000]; for (int i = 0; i < 1000; i++) array[i] = i; } private static void TestArrayList() { ArrayList array = new ArrayList(); for (int i = 0; i < 1000; i++) array.Add(i); } // Code.... long start = DateTime.Now.Ticks; TestIntArray(); long end = DateTime.Now.Ticks; Console.WriteLine("Time with int array: {0}", end - start); long start2 = DateTime.Now.Ticks; TestArrayList(); long end2 = DateTime.Now.Ticks; Console.WriteLine("Time with ArrayList array: {0}", end2 - start2);
The result:
Time

## Point multiplication in Elliptic Curves

I was browsing the web for information about the binary multiplication (also known as "left-to-right multiplication") in Ellipti curves. I wrote a demonstration of the algorithm. Unfortunately, it's very brief version, but it might be interesting for someone :) This demonstration generates the right point multiplication sequency in binary multiplication of point. First - very short theory. Point multiplication is the operation: Q = k∙P. Point multiplication is the combination of point doubling and point addition.

## Compare two bignum'bers

If you're working with bignum'bers, you'll probalby need to compare those two - are they equal, bigger, smaller etc.

## FMOD Ex-based sound system for game project

We (I and the members of my project team) are creating a game for our Project work lecture. I'm creating sound system :) I went to FMOD website and took a FMOD Ex package. There were some examples for C# :) If you want to create a sound system with C# and FMOD you need to copy at least fmod.cs file from <FMOD Ex installation directory>\api\csharp. But if you did that, also grab fmod_dsp.cs and fmod_errors.cs. They might be useful latter :) And also include in your project <FMOD Ex installation directory>\api\fmodex.dll. My not finished sound system can play sounds in multiple channels :) Right now I am thinking, should I create a universal sound playing and stopping method (something like Play(string song)), but I'll see :)

## Undefined reference to `__gxx_personality_v0'

I was compiling FMODMini library and got a terrible mistake saying that "undefined reference to `__gxx_personality_v0'". This mistake simply means, that I should use C++ compiler, instead of C :) That's it :) In FMODMini case I just edited makefile and changed gcc to g++.

## XNA. Change resolution & set full screen

I am creating a game with the XNA framework and I needed to change the resolution for XNA game. So, that's how it's done: public class MyCoolGame : Microsoft.Xna.Framework.Game // Code... // GraphicsDeviceManager graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = Width; graphics.PreferredBackBufferHeight = Height; graphics.ApplyChanges(); Another very useful property is IsFullScreen - boolean variable, which sets game to full screen or not (do not forget to call graphics.ApplyChanges().).

## Using interfaces in C#

Simple example with interfaces.

## Passing parameters in C#

In C we can use a function printf(), which can take different numbers of parameters. E.g.: printf("%d %s", a, b). How this can be done in C#? It can be done by keyword params: int Method(params int[] var) { int sum = 0; foreach (int i in var) sum += i; return sum; } // Code... Method(5, 2, 3); Method(64, 1); Method(9); More information: http://msdn.microsoft.com/en-us/library/w5zay9db(VS.71).aspx

## C#. Set culture info

I had one problem. My computer's Global Settings are set to the Lithuanians, but now I live in Austria. I need to change the currency of my program from litas (LTL) to euro (EUR). How could I do that? It's very simple: using System.Globalization; // Code... CultureInfo ci = new CultureInfo("de-AT"); // Code... Console.WriteLine(stringWithCurrency.ToString("C", ci)); Happy coding!