Skip to main content

Questions tagged [c#]

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

Filter by
Sorted by
Tagged with
4 votes
1 answer

Help golfing this solution further

We are doing a PCG challenge at work, and I'm submitting answers in C#. This is a modification of the "M'Kay" challenge. My solution has been deemed correct by the requirements, I'm just trying to ...
Bryan Boettcher's user avatar
1 vote
0 answers

Write a semi-compact FizzBuzz that can scale handle to "unlimited" if cases [closed]

I saw Tom Scott's video on FizzBuzz so I felt to write my own more "complex" version,this is what I came up with, its very flexibly and easy to scale, and ...
Patrik Fröhler's user avatar
-4 votes
1 answer

Four In A Row: AI Tournament [duplicate]

Four-In-A-Row AI Tournament Today, we will be playing a Four-In-A-Row tournament. However, it is not us humans playing... instead, we must have our computers battle instead! This challenge is ...
yummypasta's user avatar
8 votes
1 answer

C# First 1 (right to left) in binary number

I am trying to use C# to find the index of the first 1 (right to left) in the binary representation of a number. For example, since 100 in binary is: 0b1100100 ...
Eric Cepress's user avatar
5 votes
2 answers

Create another empty string in .NET? [closed]

I apologize if this isn't fit for this site but it is a puzzle, not all that practical, so I thought it would fit. Take this code: ...
Lasse V. Karlsen's user avatar
11 votes
4 answers

C# is the Main problem

This programming puzzle is inspired by another question which has been asked here yesterday but which was deleted by the author... The challenge: Create an executable binary (Windows .EXE or Linux ...
Martin Rosenau's user avatar
1 vote
1 answer

Make a better score than my students! [closed]

For the last day of the semester, I decided to have some fun with my students and I showed them Code Golf... poor guys, they're addicted now. The goal was to compete against the other students to ...
SteeveDroz's user avatar
  • 2,463
20 votes
1 answer

A little bool magic

Challenge Given the following C# method: ...
a-ctor's user avatar
  • 327
4 votes
0 answers

C# program containing `? null :` that is still valid without `null` [closed]

I found an old post on Jon Skeet's blog that pointed out a puzzle from a tweet by Vladimir Reshetnikov: C# quiz: write a valid C# program containing a sequence of three tokens ...
Sabre's user avatar
  • 157
8 votes
3 answers

Convert a string representation of a number to int[] in C#

What is the shortest C# statement that will convert a string representation of a number to an int[] that contains each digit? ...
JJS's user avatar
  • 181
7 votes
4 answers

Leibniz golf in C#

I'm starting with golf code. But im only do C# so I know wont be a breaking record, but I want give it a try. Leibniz Challenge is here The first line contains the number of test cases (N) which is ...
Juan Carlos Oropeza's user avatar
-2 votes
2 answers

Make the function comparing two variables with different value print True [closed]

Without changing the actual function, call it in such a way that it prints "True" ...
dav's user avatar
  • 15
-5 votes
1 answer

Throwing uncatchable ExecutionEngineException

The shortest C# code that generates an uncatchable ExecutionEngineException wins. You are not allowed to call FailFast directly or indirectly.
IS4's user avatar
  • 107
18 votes
6 answers

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 ...
user21634's user avatar
  • 215
2 votes
10 answers

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

The following code will produce a run-time error, stackoverflow exception. ...
kiss my armpit's user avatar
16 votes
6 answers

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. ...
Kendall Frey's user avatar
  • 2,473
2 votes
2 answers

Inherit from class with inaccessible abstract members and all constructors inaccessible

The class System.Globalization.EastAsianLunisolarCalendar of the mscorlib.dll assembly is non-nested ...
Jeppe Stig Nielsen's user avatar
3 votes
1 answer

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# ...
Timwi's user avatar
  • 12.9k
24 votes
1 answer

When is a giraffe not a giraffe? [closed]

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: ...
Jeppe Stig Nielsen's user avatar
-9 votes
4 answers

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: ...
PhonicUK's user avatar
  • 119
2 votes
1 answer

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. ...
istepaniuk's user avatar
1 vote
2 answers

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 "" as a string in .NET will result in the object being encoded as UTF-16, and it will consume twice ...
makerofthings7's user avatar
14 votes
5 answers

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 ...
Bali C's user avatar
  • 243
76 votes
59 answers

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 ...
jcolebrand's user avatar
  • 1,883