Round #743
10 May 2026, 15:19· csharp· Meta-Llama-3.3-70B-Instruct· r13-clean-hints
- Complexity
- band 0
- ZP / UO / OBS
- 3 / 0 / 3
- Journey weight
- 405
- Lightshift ΔL
- —
Prompt
Throw an ArgumentNullException if a parameter is null.
Zero-point index (what the engine surfaced)
ZPI-ZPI-0017 | 2026-05-10T15:19:48Z
Throw an ArgumentNullException if a parameter is null.
ZERO POINT — 3 entries (structural invariants)
● hsl(7.18, 100%, 50%) class [feature]
● hsl(0.00, 100%, 50%) public [feature]
● hsl(84.10, 100%, 50%) namespace [feature]
UNOBSERVED — 0 entries (implied truths)
OBSERVED — 3 entries (explicit in request)
◉ hsl(47.18, 100%, 15%) throw [feature]
◉ hsl(82.05, 100%, 15%) null [feature]
◉ hsl(224.62, 100%, 15%) throw [feature]
COMPLEXITY │ 6 entries │ spread: 177° │ band: LOW
Baseline response (no ZPI)
### Throwing ArgumentNullException in C#
You can throw an `ArgumentNullException` in C# using the following code:
```csharp
public void MyMethod(object parameter)
{
if (parameter == null)
{
throw new ArgumentNullException(nameof(parameter));
}
// Rest of the method implementation
}
```
In this example, `nameof(parameter)` is used to get the name of the parameter as a string. This is a good practice because it allows the compiler to check the parameter name and provides better support for refactoring.
### Best Practices
* Always specify the parameter name when throwing an `ArgumentNullException`. This helps with debugging and error reporting.
* Consider using the `ArgumentNullException` constructor that takes two parameters: the parameter name and a custom error message.
```csharp
throw new ArgumentNullException(nameof(parameter), "Parameter cannot be null");
```
### Example Use Case
Here's an example of a method that throws an `ArgumentNullException` if the input string is null:
```csharp
public void PrintString(string input)
{
if (input == null)
{
throw new ArgumentNullException(nameof(input), "Input string cannot be null");
}
Console.WriteLine(input);
}
```
You can call this method like this:
```csharp
try
{
PrintString(null);
}
catch (ArgumentNullException ex)
{
Console.WriteLine(ex.Message);
}
```
This will output: "Input string cannot be null"
Enhanced response (with ZPI)
```csharp
using System;
public class ParameterValidator
{
public static void ValidateParameter(object parameter, string parameterName)
{
if (parameter == null)
{
throw new ArgumentNullException(parameterName, $"{parameterName} cannot be null.");
}
}
}
public class Program
{
public static void Main()
{
try
{
object obj = null;
ParameterValidator.ValidateParameter(obj, nameof(obj));
}
catch (ArgumentNullException ex)
{
Console.WriteLine(ex.Message);
}
}
}
```
This code defines a `ParameterValidator` class with a `ValidateParameter` method that checks if a given parameter is null. If the parameter is null, it throws an `ArgumentNullException` with a message indicating the name of the parameter that is null.
In the `Main` method, we demonstrate how to use this validation method. We create a null object and pass it to the `ValidateParameter` method along with its name. Since the object is null, the method throws an `ArgumentNullException`, which we catch and print to the console.
The `nameof` operator is used to get the name of the parameter as a string, which is then passed to the `ValidateParameter` method. This approach helps to avoid magic strings and makes the code more maintainable.
Grader chain
Each grader reads the same baseline + enhanced pair and casts an independent verdict. Disagreement is the framework's own signal — not noise to be averaged away.
V1samba/Meta-Llama-3.3-70B-Instruct
BetterV4qwen2.5-coder-3b-instruct
BetterV5openrouter/qwen/qwen3-235b-a22b-2507
BetterV7qwen2.5-coder-7b-instruct
BetterV8openai/gpt-4.1
BetterV9anthropic/claude-opus-4-7
WorseV12openai/gpt-4o
BetterComments
Our grader said what it said. What do you say? Comment as a guest below.
No comments yet. Be the first to say what you make of this round.