This challenge is related to the C# language. Note that challenges that require the answers to be in a specific language are generally discouraged.

learn more… | top users | synonyms

-3
votes
1answer
213 views

Throwing uncatchable ExecutionEngineException

The shortest C# code that generates an uncatchable ExecutionEngineException wins. You are not allowed to call FailFast directly or indirectly.
14
votes
4answers
930 views

reach catch when everything in the try block is caught already

This is limited to Java and C# by the syntax I guess. In this programming puzzle, you are to produce Exceptions that can be caught but are thrown again at the end of the catch block. try { ...
3
votes
10answers
2k views

Can you cancel the stackoverflow exception in the following code? [closed]

The following code will produce a run-time error, stackoverflow exception. class Foo { //static Foo foo = new Foo(); // you are not allowed using this approach //static readonly Foo foo = ...
13
votes
5answers
1k views

Code Injection works in C# too!

Given the following C# program outputting False, inject a 'malicious' line of code such that the program outputs True. class Program { static void Main() { ...
1
vote
2answers
312 views

Inherit from class with inaccessible abstract members and all constructors inaccessible

The class System.Globalization.EastAsianLunisolarCalendar of the mscorlib.dll assembly is non-nested public but its sole instance constructor is internal and it also declares some internal abstract ...
3
votes
1answer
558 views

Flip the commented-out code [closed]

This puzzle works for any programming language that has the same // single-line and /* ... */ multi-line comments that C++, C# and Java do. You are debugging an application. You find a fishy block of ...
16
votes
1answer
891 views

When is a giraffe not a giraffe?

I hope this kind of "riddle" is ontopic in Programming Puzzles & Code Golf. Give an example of a situation where the C# method below returns false: public class Giraffe : Animal { public bool ...
-7
votes
4answers
486 views

Write 'hello world' to standard output without using certain common words - C# only [duplicate]

The challenge is to write the string hello world to your processes standard output, using as few characters of code as possible. The following restrictions apply: The following words may not appear ...
2
votes
1answer
557 views

Write the implementation to pass this test

Given the following test, implement an addOne function in C# so it passes, without any modification to the test. TIP: Yes, it is possible. [TestMethod] public void TheChallenge() { int a = 1; ...
0
votes
2answers
246 views

Storing a DNS name as compactly as possible in memory (preferably in C#) [closed]

What is the most compact way to encode/save DNS names in memory? For example, storing "www.google.com" as a string in .NET will result in the object being encoded as UTF-16, and it will consume twice ...
8
votes
9answers
3k views

Shortest Hello World program with no semi colons

I recently saw some questions on SO that asked if you could make a Hello World program without using any semi colons using C#. The challenge is to do this again, but in the shortest amount of code ...
17
votes
18answers
3k views

Tips for code-golfing in C#

What general tips do you have for golfing in C#? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to C# (e.g. "remove comments" is not an ...