This challenge is intended to utilize the C# language as a means of solving a problem. However, language-specific challenges are generally discouraged on CG.
0
votes
8answers
711 views
Can you cancel the stackoverflow exception in the following code?
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 = ...
11
votes
3answers
512 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
157 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 ...
2
votes
1answer
353 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 ...
8
votes
1answer
482 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 ...
-6
votes
4answers
265 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 ...
1
vote
1answer
356 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
205 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 ...
5
votes
9answers
2k 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 ...
12
votes
14answers
1k 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 ...