return answer to life, universe and everything else in csharp

In C#, you can return the answer to life, universe and everything else (which is 42) by writing a simple function with a return statement that returns the integer value 42. Here's an example:

main.cs
public int AnswerToLifeUniverseAndEverything()
{
    return 42;
}
66 chars
5 lines

You can call this function from your main program like this:

main.cs
int answer = AnswerToLifeUniverseAndEverything();
Console.WriteLine(answer);
77 chars
3 lines

This will output 42 to the console.

gistlibby LogSnag