71 lines
2.1 KiB
C#
71 lines
2.1 KiB
C#
|
|
using System;
|
||
|
|
using System.Text;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
|
||
|
|
// Unicode comment: δ½ ε₯½δΈη ππ
|
||
|
|
|
||
|
|
public class EdgeCases
|
||
|
|
{
|
||
|
|
public static void Main()
|
||
|
|
{
|
||
|
|
// Unicode string literals
|
||
|
|
string unicode = "γγγ«γ‘γ―δΈη";
|
||
|
|
Console.WriteLine(unicode);
|
||
|
|
|
||
|
|
// Null byte embedded
|
||
|
|
string nullStr = "hello\x00world";
|
||
|
|
Console.WriteLine($"Null-str length: {nullStr.Length}");
|
||
|
|
|
||
|
|
// Deeply nested generics
|
||
|
|
var deep = new Dictionary<int, Dictionary<int, Dictionary<int, Dictionary<int, Dictionary<int, string>>>>>
|
||
|
|
{
|
||
|
|
{ 1, new Dictionary<int, Dictionary<int, Dictionary<int, Dictionary<int, string>>>>
|
||
|
|
{
|
||
|
|
{ 2, new Dictionary<int, Dictionary<int, Dictionary<int, string>>>
|
||
|
|
{
|
||
|
|
{ 3, new Dictionary<int, Dictionary<int, string>>
|
||
|
|
{
|
||
|
|
{ 4, new Dictionary<int, string> { { 5, "deep" } } }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
Console.WriteLine(deep[1][2][3][4][5]);
|
||
|
|
|
||
|
|
// Very long string
|
||
|
|
string longStr = new string('x', 10000);
|
||
|
|
Console.WriteLine($"Long string length: {longStr.Length}");
|
||
|
|
|
||
|
|
// BOM prefix
|
||
|
|
byte[] bom = { 0xEF, 0xBB, 0xBF, (byte)'H', (byte)'i' };
|
||
|
|
Console.WriteLine(Encoding.UTF8.GetString(bom));
|
||
|
|
|
||
|
|
// Deep exception nesting
|
||
|
|
try
|
||
|
|
{
|
||
|
|
try
|
||
|
|
{
|
||
|
|
try
|
||
|
|
{
|
||
|
|
throw new InvalidOperationException("inner");
|
||
|
|
}
|
||
|
|
catch (Exception ex)
|
||
|
|
{
|
||
|
|
throw new ApplicationException("middle", ex);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
catch (Exception ex)
|
||
|
|
{
|
||
|
|
throw new Exception("outer", ex);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
catch (Exception ex)
|
||
|
|
{
|
||
|
|
Console.WriteLine($"Nested exception: {ex.Message}");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|