using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Text.RegularExpressions;

#<INSERT>

class InventoryManagerTest {
    public static int Main(string[] args) {
        bool allTestsPassed = true;

        // Test case 1
        long result1 = InventoryManager.CalculatePeaches("4 bananas and 5 grapes", 15);
        if (result1 != 6) {
            Console.WriteLine($"Test case 1 failed: expected 6, got {result1}");
            allTestsPassed = false;
        }

        // Test case 2
        long result2 = InventoryManager.CalculatePeaches("0 bananas and 1 grapes", 3);
        if (result2 != 2) {
            Console.WriteLine($"Test case 2 failed: expected 2, got {result2}");
            allTestsPassed = false;
        }

        // Test case 3
        long result3 = InventoryManager.CalculatePeaches("2 bananas and 3 grapes", 100);
        if (result3 != 95) {
            Console.WriteLine($"Test case 3 failed: expected 95, got {result3}");
            allTestsPassed = false;
        }

        // Test case 4
        long result4 = InventoryManager.CalculatePeaches("100 bananas and 1 grapes", 120);
        if (result4 != 19) {
            Console.WriteLine($"Test case 4 failed: expected 19, got {result4}");
            allTestsPassed = false;
        }

        // Test case 5
        long result5 = InventoryManager.CalculatePeaches("10 bananas and 20 grapes", 50);
        if (result5 != 20) {
            Console.WriteLine($"Test case 5 failed: expected 20, got {result5}");
            allTestsPassed = false;
        }

        if (allTestsPassed) {
            Console.WriteLine("All test cases passed successfully.");
            return 0;
        } else {
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Text.RegularExpressions;
class InventoryManager {
    public static long CalculatePeaches(string fruitCounts, long totalFruits) {
        var numbers = Regex.Matches(fruitCounts, @"\d+").Cast<Match>().Select(m => long.Parse(m.Value)).ToArray();
        long bananas = numbers[0];
        long grapes = numbers[1];
        long peaches = totalFruits - (bananas + grapes);
        return peaches;
    }
    public static void Check() {
        Debug.Assert(CalculatePeaches("4 bananas and 5 grapes", 15) == 6);
        Debug.Assert(CalculatePeaches("0 bananas and 1 grapes", 3) == 2);
        Debug.Assert(CalculatePeaches("2 bananas and 3 grapes", 100) == 95);
        Debug.Assert(CalculatePeaches("100 bananas and 1 grapes", 120) == 19);
        Console.WriteLine("All test cases passed successfully.");
    }

}

想象一下，你正在开发一个帮助管理杂货店库存的软件。你被分配了一项任务，要求编写一段代码来计算一个混合水果篮中特定水果的数量，比如香蕉。篮子里混合了香蕉、葡萄和桃子。你得到一个代表篮子中香蕉和葡萄总数的字符串和一个表示篮子里水果总数的整数。你的任务是返回篮子中的桃子数量。

例如，如果输入字符串是“4 bananas and 5 grapes”，而篮子里的水果总数是15，那么你的代码应该返回6，表示篮子里有6个桃子。

你能写一个解决这个问题的C#函数吗？

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class InventoryManager
{
    public static long CalculatePeaches(string fruitCounts, long totalFruits) {
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;

#<INSERT>

class PositiveFilterTest
{
    /// <summary>
    /// Checks if the FilterPositiveIntegers method returns the correct result.
    /// </summary>
    /// <param name="input">The input list to filter.</param>
    /// <param name="expected">The expected result after filtering.</param>
    /// <returns>True if the test passes, false otherwise.</returns>
    static bool CheckFunction(List<int> input, List<int> expected)
    {
        List<int> result = PositiveFilter.FilterPositiveIntegers(input);
        bool isCorrect = result.SequenceEqual(expected);
        Console.WriteLine($"Input: {string.Join(", ", input)}");
        Console.WriteLine($"Expected: {string.Join(", ", expected)}");
        Console.WriteLine($"Result: {string.Join(", ", result)}");
        Console.WriteLine(isCorrect ? "Test Passed" : "Test Failed");
        Console.WriteLine();
        return isCorrect;
    }

    static void Main()
    {
        bool allTestsPassed = true;

        allTestsPassed &= CheckFunction(new List<int> { -1, 2, -4, 5, 6 }, new List<int> { 2, 5, 6 });
        allTestsPassed &= CheckFunction(new List<int> { 5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10 }, new List<int> { 5, 3, 2, 3, 9, 123, 1 });
        allTestsPassed &= CheckFunction(new List<int> { -1, -2, -3, -4, -5 }, new List<int> { });
        allTestsPassed &= CheckFunction(new List<int> { 1, 2, 3, 4, 5 }, new List<int> { 1, 2, 3, 4, 5 });

        if (allTestsPassed)
        {
            Console.WriteLine("All tests passed.");
            Environment.Exit(0);
        }
        else
        {
            Console.WriteLine("Some tests failed.");
            Environment.Exit(-1);
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;
class PositiveFilter
{
    public static List<int> FilterPositiveIntegers(List<int> numbers)
    {
        return numbers.Where(n => n > 0).ToList();
    }
}
class Program
{
    , new List<int> { 2, 5, 6 });
        CheckFunction(new List<int> { 5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10 }, new List<int> { 5, 3, 2, 3, 9, 123, 1 });
    }
    static void CheckFunction(List<int> input, List<int> expected)
    {
        List<int> result = PositiveFilter.FilterPositiveIntegers(input);
        bool isCorrect = result.SequenceEqual(expected);
        Console.WriteLine($"Input: {string.Join(", ", input)}");
        Console.WriteLine($"Expected: {string.Join(", ", expected)}");
        Console.WriteLine($"Result: {string.Join(", ", result)}");
        Console.WriteLine(isCorrect ? "Test Passed" : "Test Failed");
        Console.WriteLine();
    }
}

嗨！我有一个小的C#编程挑战。你能写一个方法，从列表中过滤掉所有非正整数，并返回一个只包含正整数的新列表吗？请确保在代码片段的开头包含所有必要的导入。还请提供一个带有一些测试用例的检查函数，以确保你的解决方案按预期工作。让我看看你能做什么！

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class PositiveFilter
{
    public static List<int> FilterPositiveIntegers(List<int> numbers)
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class CharacterFrequencyAnalyzerTest
{
    public static int Main(string[] args)
    {
        var testCases = new List<Tuple<string, Dictionary<char, int>>>
        {
            new Tuple<string, Dictionary<char, int>>("hello world", new Dictionary<char, int> { {'h', 1}, {'e', 1}, {'l', 3}, {'o', 2}, {' ', 1}, {'w', 1}, {'r', 1}, {'d', 1} }),
            new Tuple<string, Dictionary<char, int>>("aabbcc", new Dictionary<char, int> { {'a', 2}, {'b', 2}, {'c', 2} }),
            new Tuple<string, Dictionary<char, int>>("123321", new Dictionary<char, int> { {'1', 2}, {'2', 2}, {'3', 2} }),
            new Tuple<string, Dictionary<char, int>>("", new Dictionary<char, int> { }),
            new Tuple<string, Dictionary<char, int>>("abcde", new Dictionary<char, int> { {'a', 1}, {'b', 1}, {'c', 1}, {'d', 1}, {'e', 1} })
        };

        foreach (var testCase in testCases)
        {
            var result = CharacterFrequencyAnalyzer.AnalyzeCharacterFrequency(testCase.Item1);
            if (!IsEqual(result, testCase.Item2))
            {
                Console.WriteLine($"Test Failed for input: {testCase.Item1}");
                return -1;
            }
        }

        Console.WriteLine("All tests passed.");
        return 0;
    }

    private static bool IsEqual(Dictionary<char, int> dict1, Dictionary<char, int> dict2)
    {
        if (dict1.Count != dict2.Count) return false;

        foreach (var pair in dict1)
        {
            if (!dict2.ContainsKey(pair.Key) || dict2[pair.Key] != pair.Value)
            {
                return false;
            }
        }

        return true;
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class CharacterFrequencyAnalyzer
{
    public static Dictionary<char, int> AnalyzeCharacterFrequency(string input)
    {
        Dictionary<char, int> characterFrequencies = new Dictionary<char, int>();
        foreach (char character in input)
        {
            if (characterFrequencies.ContainsKey(character))
            {
                characterFrequencies[character]++;
            }
            else
            {
                characterFrequencies.Add(character, 1);
            }
        }
        return characterFrequencies;
    }
    public static void CheckFunction()
    {
        var testString = "hello world";
        var expectedResult = new Dictionary<char, int> { {'h', 1}, {'e', 1}, {'l', 3}, {'o', 2}, {' ', 1}, {'w', 1}, {'r', 1}, {'d', 1} };
        var result = AnalyzeCharacterFrequency(testString);
        Console.WriteLine("Testing with input: " + testString);
        foreach (var pair in expectedResult)
        {
            if (!result.ContainsKey(pair.Key) || result[pair.Key] != pair.Value)
            {
                Console.WriteLine("Test Failed.");
                return;
            }
        }
        Console.WriteLine("Test Passed.");
    }

}

想象一下，你正在处理一个需要分析文本数据的项目。你需要完成的任务之一是确定给定字符串中每个字符的频率。然而，为了使分析更加深入，你只对唯一字符及其计数感兴趣。你的挑战是编写一个C#程序，该程序接受一个字符串作为输入，并返回一个字典，其中每个键是字符串中的一个唯一字符，相应的值是该字符在字符串中出现的次数。

例如，如果输入字符串是 "hello world"，则输出应该是一个字典，其中包含类似 {'h': 1, 'e': 1, 'l': 3, 'o': 2, ...} 的条目。

确保你的解决方案是高效的，并能优雅地处理边缘情况，例如空字符串。

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class CharacterFrequencyAnalyzer
{
    public static Dictionary<char, int> AnalyzeCharacterFrequency(string input)
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;

#<INSERT>

class DataAnalyzerTest
{
    public static int Main(string[] args)
    {
        bool allTestsPassed = true;

        // Test case 1
        List<int> testData1 = new List<int> { 5, 3, 5, 2, 3, 3, 9, 0, 123 };
        List<int> expectedResult1 = new List<int> { 0, 2, 3, 5, 9, 123 };
        List<int> result1 = DataAnalyzer.GetUniqueSortedNumbers(testData1);
        allTestsPassed &= result1.SequenceEqual(expectedResult1);

        // Test case 2
        List<int> testData2 = new List<int> { 1, 2, 3, 4, 5 };
        List<int> expectedResult2 = new List<int> { 1, 2, 3, 4, 5 };
        List<int> result2 = DataAnalyzer.GetUniqueSortedNumbers(testData2);
        allTestsPassed &= result2.SequenceEqual(expectedResult2);

        // Test case 3
        List<int> testData3 = new List<int> { 9, 7, 5, 3, 1, 1, 3, 5, 7, 9 };
        List<int> expectedResult3 = new List<int> { 1, 3, 5, 7, 9 };
        List<int> result3 = DataAnalyzer.GetUniqueSortedNumbers(testData3);
        allTestsPassed &= result3.SequenceEqual(expectedResult3);

        // Test case 4
        List<int> testData4 = new List<int> { -1, -2, -3, -4, -5, -1, -2, -3, -4, -5 };
        List<int> expectedResult4 = new List<int> { -5, -4, -3, -2, -1 };
        List<int> result4 = DataAnalyzer.GetUniqueSortedNumbers(testData4);
        allTestsPassed &= result4.SequenceEqual(expectedResult4);

        // Test case 5
        List<int> testData5 = new List<int> { };
        List<int> expectedResult5 = new List<int> { };
        List<int> result5 = DataAnalyzer.GetUniqueSortedNumbers(testData5);
        allTestsPassed &= result5.SequenceEqual(expectedResult5);

        if (allTestsPassed)
        {
            return 0;
        }
        else
        {
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;
class DataAnalyzer
{
    public static List<int> GetUniqueSortedNumbers(List<int> numbers)
    {
        HashSet<int> uniqueNumbers = new HashSet<int>(numbers);
        List<int> sortedUniqueNumbers = uniqueNumbers.ToList();
        sortedUniqueNumbers.Sort();
        return sortedUniqueNumbers;
    }
    public static void CheckFunction()
    {
        List<int> testData = new List<int> { 5, 3, 5, 2, 3, 3, 9, 0, 123 };
        List<int> expectedResult = new List<int> { 0, 2, 3, 5, 9, 123 };
        List<int> result = GetUniqueSortedNumbers(testData);
        Console.WriteLine($"Test Result: { (result.SequenceEqual(expectedResult) ? "Success" : "Failure") }");
    }

}

想象一下，你正在进行一个项目，需要分析一组数据点，特别是整数，以识别其中的模式。然而，你的分析需要每个数据点都是唯一的，并以升序排列，以提高模式识别过程的效率。你决定编写一个 C# 方法，该方法接受一个整数列表作为输入，去除任何重复项，然后返回一个仅包含唯一元素并按升序排序的新列表。你将如何设计这样一个 C# 方法，确保其高效并遵循最佳编码实践？

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class DataAnalyzer
{
    public static List<int> GetUniqueSortedNumbers(List<int> numbers)
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class GradeConverterTest {
    public static int Main(string[] args) {
        bool allTestsPassed = true;

        // Test Case 1
        List<int> input1 = new List<int> { 100, 92, 87, 81, 76, 71, 66, 61, 56, 51, 46, 41, 35 };
        List<string> expected1 = new List<string> { "A+", "A", "A-", "B+", "B", "B-", "C+", "C", "C-", "D+", "D", "D-", "E" };
        List<string> result1 = GradeConverter.ConvertNumericalToLetterGrades(input1);
        allTestsPassed &= result1.SequenceEqual(expected1);

        // Test Case 2
        List<int> input2 = new List<int> { 85, 70, 55, 40, 39 };
        List<string> expected2 = new List<string> { "A-", "B-", "C-", "D-", "E" };
        List<string> result2 = GradeConverter.ConvertNumericalToLetterGrades(input2);
        allTestsPassed &= result2.SequenceEqual(expected2);

        // Test Case 3
        List<int> input3 = new List<int> { 95, 88, 73, 67, 52 };
        List<string> expected3 = new List<string> { "A", "A-", "B-", "C+", "D+" };
        List<string> result3 = GradeConverter.ConvertNumericalToLetterGrades(input3);
        allTestsPassed &= result3.SequenceEqual(expected3);

        // Test Case 4
        List<int> input4 = new List<int> { 99, 84, 69, 54, 44 };
        List<string> expected4 = new List<string> { "A", "B+", "C+", "D+", "D-" };
        List<string> result4 = GradeConverter.ConvertNumericalToLetterGrades(input4);
        allTestsPassed &= result4.SequenceEqual(expected4);

        return allTestsPassed ? 0 : -1;
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class GradeConverter {
    public static List<string> ConvertNumericalToLetterGrades(List<int> numericalGrades) {
        List<string> letterGrades = new List<string>();
        foreach (int grade in numericalGrades) {
            if (grade == 100) letterGrades.Add("A+");
            else if (grade >= 90) letterGrades.Add("A");
            else if (grade >= 85) letterGrades.Add("A-");
            else if (grade >= 80) letterGrades.Add("B+");
            else if (grade >= 75) letterGrades.Add("B");
            else if (grade >= 70) letterGrades.Add("B-");
            else if (grade >= 65) letterGrades.Add("C+");
            else if (grade >= 60) letterGrades.Add("C");
            else if (grade >= 55) letterGrades.Add("C-");
            else if (grade >= 50) letterGrades.Add("D+");
            else if (grade >= 45) letterGrades.Add("D");
            else if (grade >= 40) letterGrades.Add("D-");
            else letterGrades.Add("E");
        }
        return letterGrades;
    }
    public static void TestGradeConversion() {
        List<int> sampleGrades = new List<int> { 100, 92, 87, 81, 76, 71, 66, 61, 56, 51, 46, 41, 35 };
        List<string> expectedLetterGrades = new List<string> { "A+", "A", "A-", "B+", "B", "B-", "C+", "C", "C-", "D+", "D", "D-", "E" };
        List<string> actualLetterGrades = ConvertNumericalToLetterGrades(sampleGrades);
        Console.WriteLine("Expected: " + String.Join(", ", expectedLetterGrades));
        Console.WriteLine("Actual: " + String.Join(", ", actualLetterGrades));
    }

}

想象你是一名软件开发人员，任务是为一位高中老师创建一个评分系统。老师希望根据特定的评分标准将数值成绩转换为字母成绩。你的工作是编写一个C#程序，接收一个数值成绩列表作为输入，并返回相应的字母成绩列表。评分标准如下：

- **A+**: 正好 100
- **A**: 90 到 99
- **A-**: 85 到 89
- **B+**: 80 到 84
- **B**: 75 到 79
- **B-**: 70 到 74
- **C+**: 65 到 69
- **C**: 60 到 64
- **C-**: 55 到 59
- **D+**: 50 到 54
- **D**: 45 到 49
- **D-**: 40 到 44
- **E**: 低于 40

你的程序应能够处理表示数值成绩的整数列表，并输出对应的字母成绩字符串列表。请确保包含一个函数，使用一些示例成绩测试你的评分系统的正确性。

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class GradeConverter
{
    public static List<string> ConvertNumericalToLetterGrades(List<int> numericalGrades) {
    {
        // Implement your code here.
    }
}
```


#<INSERT>

public class ValueComparerTest
{
    public static int Main(string[] args)
    {
        try
        {
            // Test case 1: Integer comparison
            if (!ValueComparer.CompareValues(5, 3).Equals(5)) return -1;

            // Test case 2: Floating-point comparison
            if (!ValueComparer.CompareValues(2.5, 3.5).Equals(3.5)) return -1;

            // Test case 3: String numbers with dot as decimal separator
            if (!ValueComparer.CompareValues("1.2", "1.3").Equals("1.3")) return -1;

            // Test case 4: String numbers with comma as decimal separator
            if (!ValueComparer.CompareValues("2,5", "2,4").Equals("2,5")) return -1;

            // Test case 5: Equal values
            if (!ValueComparer.CompareValues(7, 7).Equals("None")) return -1;

            return 0; // All test cases passed
        }
        catch (Exception)
        {
            return -1; // Test case failed due to an exception
        }
    }
}

using System;
using System.Globalization;

public class ValueComparer
{
    public static object CompareValues(object value1, object value2)
    {
        if (value1 == null || value2 == null)
        {
            throw new ArgumentNullException("Values cannot be null");
        }

        double num1, num2;
        bool isValue1Numeric = TryParseToDouble(value1, out num1);
        bool isValue2Numeric = TryParseToDouble(value2, out num2);

        if (isValue1Numeric && isValue2Numeric)
        {
            if (num1 > num2) return value1;
            if (num1 < num2) return value2;
            return "None";
        }

        throw new ArgumentException("Both values must be numeric or convertible to numeric.");
    }

    private static bool TryParseToDouble(object value, out double result)
    {
        if (value is int)
        {
            result = Convert.ToDouble(value);
            return true;
        }
        if (value is double)
        {
            result = (double)value;
            return true;
        }
        if (value is string)
        {
            string strValue = (string)value;
            if (double.TryParse(strValue, NumberStyles.Float, CultureInfo.InvariantCulture, out result) ||
                double.TryParse(strValue, NumberStyles.Float, new CultureInfo("fr-FR"), out result))
            {
                return true;
            }
        }
        result = 0;
        return false;
    }
}

想象一下你正在处理一个需要比较两个值的程序。这些值可能是整数、浮点数，甚至是表示数字的字符串（小数点可以是点或逗号）。你的任务是编写一个函数来确定哪两个值更大，并以其原始形式（类型和格式）返回。如果两个值相等，你的函数应该返回字符串 “None”。你能编写一个能够优雅地处理这种比较的函数吗，考虑到输入的不同可能格式和类型？

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class ValueComparer
{
public class ValueComparer
    {
        // Implement your code here.
    }
}
```


using System;

#<INSERT>

public static class ValueComparerTest
{
    public static int Main()
    {
        bool allTestsPassed = true;

        allTestsPassed &= TestEqualIntegers();
        allTestsPassed &= TestDifferentIntegers();
        allTestsPassed &= TestEqualFloatingPoints();
        allTestsPassed &= TestDifferentFloatingPoints();
        allTestsPassed &= TestStringNumbersWithComma();

        return allTestsPassed ? 0 : -1;
    }

    private static bool TestEqualIntegers()
    {
        object result = ValueComparer.CompareValues(5, 5);
        return result.Equals("None");
    }

    private static bool TestDifferentIntegers()
    {
        object result = ValueComparer.CompareValues(3, 7);
        return result.Equals(7);
    }

    private static bool TestEqualFloatingPoints()
    {
        object result = ValueComparer.CompareValues(5.5, 5.5);
        return result.Equals("None");
    }

    private static bool TestDifferentFloatingPoints()
    {
        object result = ValueComparer.CompareValues(3.14, 2.71);
        return result.Equals(3.14);
    }

    private static bool TestStringNumbersWithComma()
    {
        object result = ValueComparer.CompareValues("1,23", "1.22");
        return result.Equals("1,23");
    }
}

using System;
using System.Globalization;

public static class ValueComparer
{
    public static object CompareValues(object value1, object value2)
    {
        if (value1 == null || value2 == null)
        {
            throw new ArgumentNullException("Both values must be non-null.");
        }

        double num1, num2;
        bool isNum1Parsed = TryParseToDouble(value1, out num1);
        bool isNum2Parsed = TryParseToDouble(value2, out num2);

        if (!isNum1Parsed || !isNum2Parsed)
        {
            throw new ArgumentException("Both values must be numeric (either integer, floating-point or numeric strings).");
        }

        if (num1 == num2)
        {
            return "None";
        }

        return num1 > num2 ? value1 : value2;
    }

    private static bool TryParseToDouble(object value, out double result)
    {
        result = 0;

        if (value is double || value is float || value is int || value is long || value is decimal)
        {
            result = Convert.ToDouble(value);
            return true;
        }

        if (value is string strValue)
        {
            strValue = strValue.Replace(",", ".");

            if (double.TryParse(strValue, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
            {
                return true;
            }
        }

        return false;
    }
}

想象一下，你正在编写一个需要比较两个值的程序。这些值可以是整数、浮点数，甚至是表示数字的字符串（小数点分隔符可以是点或逗号）。你的任务是编写一个函数来确定两个值中较大的那个，并以其原始形式（类型和格式）返回。如果两个值相等，则函数应返回字符串"None"。你能否编写一个优雅处理这种比较的函数，考虑到输入的不同可能类型和格式？

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class ValueComparer
{
public static class ValueComparer
    {
        // Implement your code here.
    }
}
```


using System;

#<INSERT>

public class ValueComparerTest
{
    public static int Main(string[] args)
    {
        bool allTestsPassed = true;

        // Test Case 1: Integer comparison
        if (!CompareTest(5, 10, 10))
        {
            allTestsPassed = false;
        }

        // Test Case 2: Floating-point comparison with dot as decimal separator
        if (!CompareTest(5.5, 3.2, 5.5))
        {
            allTestsPassed = false;
        }

        // Test Case 3: String representation of numbers with dot and comma
        if (!CompareTest("5.5", "5,5", "None"))
        {
            allTestsPassed = false;
        }

        // Test Case 4: Equal integer values
        if (!CompareTest(7, 7, "None"))
        {
            allTestsPassed = false;
        }

        // Test Case 5: String representation of numbers with different decimal separators
        if (!CompareTest("10.25", "10,25", "None"))
        {
            allTestsPassed = false;
        }

        // Return appropriate code based on test results
        return allTestsPassed ? 0 : -1;
    }

    private static bool CompareTest(object value1, object value2, object expected)
    {
        object result = ValueComparer.CompareValues(value1, value2);
        return result.Equals(expected);
    }
}

using System;
using System.Globalization;

public class ValueComparer
{
    public static object CompareValues(object value1, object value2)
    {
        // Attempt to parse the values to numbers
        if (TryParseToDouble(value1, out double num1) && TryParseToDouble(value2, out double num2))
        {
            if (num1 > num2)
            {
                return value1;
            }
            else if (num2 > num1)
            {
                return value2;
            }
            else
            {
                return "None";
            }
        }

        // If parsing fails, compare the values as strings
        string str1 = value1.ToString();
        string str2 = value2.ToString();

        if (str1.CompareTo(str2) > 0)
        {
            return value1;
        }
        else if (str2.CompareTo(str1) > 0)
        {
            return value2;
        }
        else
        {
            return "None";
        }
    }

    private static bool TryParseToDouble(object value, out double result)
    {
        if (value is double || value is float || value is int)
        {
            result = Convert.ToDouble(value);
            return true;
        }
        else if (value is string strValue)
        {
            // Try parsing with dot as decimal separator
            if (double.TryParse(strValue, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
            {
                return true;
            }

            // Try parsing with comma as decimal separator
            if (double.TryParse(strValue, NumberStyles.Any, CultureInfo.GetCultureInfo("fr-FR"), out result))
            {
                return true;
            }
        }

        result = 0;
        return false;
    }
}

想象一下，你正在编写一个程序，需要对两个值进行比较。 这些值可以是整数、浮点数，甚至是表示数字的字符串（小数点分隔符可以是点或者逗号）。 你的任务是编写一个函数，确定两个值中哪个更大，并以原始形式（类型和格式）返回它。 如果两个值相等，函数应该返回字符串 "None"。 你能设计一个函数来实现这个任务，同时无缝处理不同类型和格式吗？

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class ValueComparer
{
public class ValueComparer
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;

#<INSERT>

class BookFilterTest {
    public static int Main(string[] args) {
        var testCases = new List<Tuple<List<string>, string, List<string>>> {
            Tuple.Create(new List<string>{"Superman", "Batman", "Spiderman", "Ironman", "Thor"}, "man", new List<string>{"Superman", "Batman", "Spiderman", "Ironman"}),
            Tuple.Create(new List<string>{"Harry Potter", "Lord of the Rings", "Narnia", "Hobbit"}, "Rings", new List<string>{"Lord of the Rings"}),
            Tuple.Create(new List<string>{"Alice in Wonderland", "Peter Pan", "The Cat in the Hat"}, "Hat", new List<string>{"The Cat in the Hat"}),
            Tuple.Create(new List<string>{"The Great Gatsby", "Moby Dick", "War and Peace"}, "Peace", new List<string>{"War and Peace"})
        };

        foreach (var testCase in testCases) {
            var result = BookFilter.SelectBySuffix(testCase.Item1, testCase.Item2);
            if (!result.SequenceEqual(testCase.Item3)) {
                Console.WriteLine($"Test Failed: Input: {string.Join(", ", testCase.Item1)} Suffix: {testCase.Item2} Expected: {string.Join(", ", testCase.Item3)} Got: {string.Join(", ", result)}");
                return -1;
            }
        }

        Console.WriteLine("All tests passed.");
        return 0;
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;
class BookFilter {
    public static List<string> SelectBySuffix(List<string> titles, string suffix) {
        return titles.Where(title => title.EndsWith(suffix)).ToList();
    }
    public static void Check() {
        var testTitles = new List<string>{"Superman", "Batman", "Spiderman", "Ironman", "Thor"};
        var expectedTitles = new List<string>{"Superman", "Batman", "Spiderman", "Ironman"};
        var result = SelectBySuffix(testTitles, "man");
        Console.WriteLine($"Test Passed: {expectedTitles.SequenceEqual(result)}");
    }
}
class Program {

}

想象你正在处理一个需要组织图书标题集合的项目。你的任务是编写一个方法，该方法只选择以特定后缀结尾的标题。例如，如果你对所有以“man”结尾的书名感兴趣，你的方法应该能够从书名列表中筛选出这些书名。

编写一个C#方法，该方法接收两个参数：一个表示图书标题的字符串列表和一个表示你感兴趣的后缀的字符串。该方法应返回一个新的列表，其中只包含以指定后缀结尾的标题。

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class BookFilter
{
    public static List<string> SelectBySuffix(List<string> titles, string suffix) {
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;

#<INSERT>

class NumberFilterTest {
    public static void Main(string[] args) {
        int result = -1;
        if (Test1() && Test2() && Test3()) {
            result = 0;
        }
        Console.WriteLine("All tests passed: " + (result == 0));
        Environment.Exit(result);
    }

    private static bool Test1() {
        var input = new List<int>{15, 33, 1422, 1};
        var expected = new List<int>{1, 15, 33};
        var output = NumberFilter.FilterOddDigitNumbers(input);
        return output.SequenceEqual(expected);
    }

    private static bool Test2() {
        var input = new List<int>{152, 323, 1422, 10};
        var expected = new List<int>{};
        var output = NumberFilter.FilterOddDigitNumbers(input);
        return output.SequenceEqual(expected);
    }

    private static bool Test3() {
        var input = new List<int>{111, 113, 115, 117};
        var expected = new List<int>{111, 113, 115, 117};
        var output = NumberFilter.FilterOddDigitNumbers(input);
        return output.SequenceEqual(expected);
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;
class NumberFilter {
    public static List<int> FilterOddDigitNumbers(List<int> numbers) {
        return numbers.Where(number => number.ToString().All(c => "13579".Contains(c)))
                      .OrderBy(number => number)
                      .ToList();
    }
    public static void Check() {
        var test1 = new List<int>{15, 33, 1422, 1};
        var expected1 = new List<int>{1, 15, 33};
        Debug.Assert(FilterOddDigitNumbers(test1).SequenceEqual(expected1));
        var test2 = new List<int>{152, 323, 1422, 10};
        var expected2 = new List<int>{};
        Debug.Assert(FilterOddDigitNumbers(test2).SequenceEqual(expected2));
        Console.WriteLine("All tests passed successfully.");
    }

}

想象一下，你正在开发一个处理数值数据的软件。你遇到了一个特定的需求：从给定的正整数列表中，筛选出并返回一个新列表，其中仅包含那些不含任何偶数字的数字。此外，结果列表中的数字应按升序排列。你将如何在C#中实现这个需求的函数？

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class NumberFilter
{
    public static List<int> FilterOddDigitNumbers(List<int> numbers) {
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;

#<INSERT>

class UniqueFilterTest
{
    public static int Main()
    {
        bool allTestsPass = true;

        // Test Case 1
        List<int> testList1 = new List<int> { 1, 2, 3, 2, 4 };
        List<int> expected1 = new List<int> { 2, 2 };
        List<int> result1 = UniqueFilter.FilterNonUniqueNumbers(testList1);
        if (!result1.SequenceEqual(expected1))
        {
            Console.WriteLine("Test Case 1 Failed");
            allTestsPass = false;
        }

        // Test Case 2
        List<int> testList2 = new List<int> { 1, 1, 1, 1, 1 };
        List<int> expected2 = new List<int> { 1, 1, 1, 1, 1 };
        List<int> result2 = UniqueFilter.FilterNonUniqueNumbers(testList2);
        if (!result2.SequenceEqual(expected2))
        {
            Console.WriteLine("Test Case 2 Failed");
            allTestsPass = false;
        }

        // Test Case 3
        List<int> testList3 = new List<int> { 1, 2, 3, 4, 5 };
        List<int> expected3 = new List<int> { };
        List<int> result3 = UniqueFilter.FilterNonUniqueNumbers(testList3);
        if (!result3.SequenceEqual(expected3))
        {
            Console.WriteLine("Test Case 3 Failed");
            allTestsPass = false;
        }

        // Test Case 4
        List<int> testList4 = new List<int> { 5, 5, 4, 4, 3, 3, 2, 2, 1, 1 };
        List<int> expected4 = new List<int> { 5, 5, 4, 4, 3, 3, 2, 2, 1, 1 };
        List<int> result4 = UniqueFilter.FilterNonUniqueNumbers(testList4);
        if (!result4.SequenceEqual(expected4))
        {
            Console.WriteLine("Test Case 4 Failed");
            allTestsPass = false;
        }

        // Test Case 5
        List<int> testList5 = new List<int> { 10, 20, 30, 20, 10, 40 };
        List<int> expected5 = new List<int> { 10, 20, 20, 10 };
        List<int> result5 = UniqueFilter.FilterNonUniqueNumbers(testList5);
        if (!result5.SequenceEqual(expected5))
        {
            Console.WriteLine("Test Case 5 Failed");
            allTestsPass = false;
        }

        if (allTestsPass)
        {
            Console.WriteLine("All test cases passed.");
            return 0;
        }
        else
        {
            Console.WriteLine("Some test cases failed.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;
class UniqueFilter
{
    public static List<int> FilterNonUniqueNumbers(List<int> numbers)
    {
        var numberCounts = numbers.GroupBy(n => n)
                                  .ToDictionary(group => group.Key, group => group.Count());
        return numbers.Where(n => numberCounts[n] > 1).ToList();
    }
}
class Program
{
    ;
        List<int> filteredList = UniqueFilter.FilterNonUniqueNumbers(testList);
        Console.WriteLine("Filtered List: " + string.Join(", ", filteredList));
    }
}

你能写一个C#方法来过滤出列表中只出现一次的所有数字吗？该方法应保留未过滤掉的数字的原始顺序。例如，如果输入列表是 `[1, 2, 3, 2, 4]`，输出应为 `[2, 2]`，因为数字2是唯一一个出现多次的数字。

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class UniqueFilter
{
    public static List<int> FilterNonUniqueNumbers(List<int> numbers)
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;

#<INSERT>

class RoundingAssistantTest {
    public static int Main(string[] args) {
        int result = 0;

        // Test cases
        if (RoundingAssistant.RoundDecimal("10.5") != 11) result = -1;
        if (RoundingAssistant.RoundDecimal("2.5") != 3) result = -1;
        if (RoundingAssistant.RoundDecimal("-2.5") != -3) result = -1;
        if (RoundingAssistant.RoundDecimal("10") != 10) result = -1;
        if (RoundingAssistant.RoundDecimal("-10") != -10) result = -1;

        return result;
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;
class RoundingAssistant {
    public static int RoundDecimal(string numberString) {
        decimal number = decimal.Parse(numberString);
        decimal fractionalPart = number % 1;
        if (Math.Abs(fractionalPart) == 0.5m) {
            if (number > 0) {
                return (int)(number - fractionalPart + 1);
            } else {
                return (int)(number - fractionalPart - 1);
            }
        } else {
            return (int)Math.Round(number, MidpointRounding.AwayFromZero);
        }
    }
    public static void Check() {
        Console.WriteLine(RoundDecimal("10.5"));
        Console.WriteLine(RoundDecimal("2.5"));
        Console.WriteLine(RoundDecimal("-2.5"));
        Console.WriteLine(RoundDecimal("10"));
        Console.WriteLine(RoundDecimal("-10"));
    }
}
class Program {

}

想象一下，你正在开发一个财务应用程序，其中精度至关重要。你需要编写一个方法，将表示为字符串的小数准确地四舍五入到最接近的整数。然而，这里有一个变数：如果小数正好位于两个整数的中间，你应该将其向远离零的方向四舍五入。这意味着，例如，2.5 变为 3，而 -2.5 变为 -3。你能编写一个 C# 方法来处理这种四舍五入策略吗？

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class RoundingAssistant
{
    public static int RoundDecimal(string numberString) {
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;

#<INSERT>

class FinancialAnalyzerTest
{
    public static int Main(string[] args)
    {
        var testCases = new List<Tuple<List<int>, Tuple<int, double>>>
        {
            Tuple.Create(new List<int> { 100, 150, 200, 250 }, Tuple.Create(4, 175.0)),
            Tuple.Create(new List<int>(), Tuple.Create(0, 0.0)),
            Tuple.Create(new List<int> { 50, 75, 100 }, Tuple.Create(3, 75.0)),
            Tuple.Create(new List<int> { -100, 0, 100 }, Tuple.Create(3, 0.0)),
            Tuple.Create(new List<int> { 1000 }, Tuple.Create(1, 1000.0))
        };

        foreach (var testCase in testCases)
        {
            var result = FinancialAnalyzer.CalculateStats(testCase.Item1);
            if (result.Item1 != testCase.Item2.Item1 || result.Item2 != testCase.Item2.Item2)
            {
                Console.WriteLine($"Test failed for input {testCase.Item1}: Expected ({testCase.Item2.Item1}, {testCase.Item2.Item2}), Got ({result.Item1}, {result.Item2})");
                return -1;
            }
        }

        Console.WriteLine("All tests passed successfully.");
        return 0;
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;
class FinancialAnalyzer
{
    public static Tuple<int, double> CalculateStats(List<int> transactions)
    {
        if (transactions == null || transactions.Count == 0)
        {
            return Tuple.Create(0, 0.0);
        }
        else
        {
            int totalTransactions = transactions.Count;
            double averageAmount = transactions.Average();
            return Tuple.Create(totalTransactions, averageAmount);
        }
    }
    ;
        var result = CalculateStats(transactions);
        Console.WriteLine($"Total Transactions: {result.Item1}, Average Amount: {result.Item2}");
        var emptyTransactions = new List<int>();
        var emptyResult = CalculateStats(emptyTransactions);
        Console.WriteLine($"Total Transactions: {emptyResult.Item1}, Average Amount: {emptyResult.Item2}");
    }
}

想象一下，你正在开发一个财务分析工具，需要处理一系列交易。每笔交易都有一个相关的金额。你的任务是编写一个方法，该方法接受这些交易金额（整数）列表并返回交易总数和平均交易金额。然而，如果没有交易，平均值应报告为0。你能编写一个C#方法来完成这个任务吗？

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class FinancialAnalyzer
{
    public static Tuple<int, double> CalculateStats(List<int> transactions)
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;

#<INSERT>

public class TextProcessorTest
{
    public static int Main(string[] args)
    {
        var testCases = new List<Tuple<string, List<string>>>
        {
            Tuple.Create("Hello; world, welcome to coding", new List<string> { "Hello", "world,", "welcome", "to", "coding" }),
            Tuple.Create("Coding;is;fun;and;educational", new List<string> { "Coding", "is", "fun", "and", "educational" }),
            Tuple.Create("Semicolons; are; also; separators", new List<string> { "Semicolons", "are", "also", "separators" })
        };

        bool allTestsPassed = true;

        foreach (var testCase in testCases)
        {
            var result = TextProcessor.SplitText(testCase.Item1);
            if (result.SequenceEqual(testCase.Item2))
            {
                Console.WriteLine($"Test passed for: {testCase.Item1}");
            }
            else
            {
                Console.WriteLine($"Test failed for: {testCase.Item1}");
                allTestsPassed = false;
            }
        }

        if (allTestsPassed)
        {
            return 0;
        }
        else
        {
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;
public class TextProcessor
{
    Takes a string containing words separated by semicolons or spaces and returns a list of words without semicolons.
    Example:
    - For the input "Hello; world, welcome to coding", the output should be a list: ["Hello", "world", "welcome", "to", "coding"].
    - For "Coding;is;fun;and;educational", the output should be: ["Coding", "is", "fun", "and", "educational"].
    public static List<string> SplitText(string text)
    {
        if (string.IsNullOrEmpty(text))
        {
            return new List<string>();
        }
        string unifiedText = text.Replace(';', ' ');
        return unifiedText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    }
    public static void CheckFunction()
    {
        var testData = new Dictionary<string, List<string>>()
        {
            { "Hello; world, welcome to coding", new List<string> { "Hello", "world,", "welcome", "to", "coding" } },
            { "Coding;is;fun;and;educational", new List<string> { "Coding", "is", "fun", "and", "educational" } }
        };
        foreach (var item in testData)
        {
            var result = SplitText(item.Key);
            if (result.SequenceEqual(item.Value))
            {
                Console.WriteLine($"Test passed for: {item.Key}");
            }
            else
            {
                Console.WriteLine($"Test failed for: {item.Key}");
            }
        }
    }
}
class Program
{

}

想象你正在处理一个文本处理应用程序，需要处理包含多个句子的字符串。这些句子由分号或空格隔开。你的任务是编写一个方法，该方法接受这样的字符串并返回一个不含分号的单词列表。

例如，如果你输入字符串 "Hello; world, welcome to coding"，你的方法应该返回包含 ["Hello", "world", "welcome", "to", "coding"] 的列表。同样地，对于 "Coding;is;fun;and;educational"，输出应为 ["Coding", "is", "fun", "and", "educational"]。

你能编写一个高效执行此任务的 C# 方法吗？

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class TextProcessor
{
public class TextProcessor
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class TemperatureFilterTest {
    public static void Main(string[] args) {
        int result = RunTests();
        Environment.Exit(result);
    }

    public static int RunTests() {
        bool allTestsPassed = true;

        // Test Case 1
        List<int> test1 = TemperatureFilter.FilterNonNegativeTemperatures(new List<int>{-5, 23, -2, 0, 15, -8, 30});
        List<int> expected1 = new List<int>{23, 0, 15, 30};
        allTestsPassed &= test1.SequenceEqual(expected1);

        // Test Case 2
        List<int> test2 = TemperatureFilter.FilterNonNegativeTemperatures(new List<int>{-1, -3, -5, -7});
        List<int> expected2 = new List<int>{};
        allTestsPassed &= test2.SequenceEqual(expected2);

        // Test Case 3
        List<int> test3 = TemperatureFilter.FilterNonNegativeTemperatures(new List<int>{10, 20, 30, 40, 50});
        List<int> expected3 = new List<int>{10, 20, 30, 40, 50};
        allTestsPassed &= test3.SequenceEqual(expected3);

        // Test Case 4
        List<int> test4 = TemperatureFilter.FilterNonNegativeTemperatures(new List<int>{-10, -20, -30, -40, -50});
        List<int> expected4 = new List<int>{};
        allTestsPassed &= test4.SequenceEqual(expected4);

        if (allTestsPassed) {
            Console.WriteLine("All tests passed successfully.");
            return 0;
        } else {
            Console.WriteLine("There are test failures.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class TemperatureFilter {
    public static List<int> FilterNonNegativeTemperatures(List<int> temperatures) {
        List<int> nonNegativeTemperatures = new List<int>();
        foreach (int temp in temperatures) {
            if (temp >= 0) {
                nonNegativeTemperatures.Add(temp);
            }
        }
        return nonNegativeTemperatures;
    }
    public static void Check() {
        bool isCorrect = true;
        List<int> test1 = FilterNonNegativeTemperatures(new List<int>{-5, 23, -2, 0, 15, -8, 30});
        List<int> expected1 = new List<int>{23, 0, 15, 30};
        isCorrect &= test1.SequenceEqual(expected1);
        List<int> test2 = FilterNonNegativeTemperatures(new List<int>{-1, -3, -5, -7});
        List<int> expected2 = new List<int>{};
        isCorrect &= test2.SequenceEqual(expected2);
        if (isCorrect) {
            Console.WriteLine("All tests passed successfully.");
        } else {
            Console.WriteLine("There are test failures.");
        }
    }

}

假设你正在做一个项目，要求从每日温度读数列表中筛选出所有负温度。读数是整数形式的摄氏温度。你的任务是编写一个方法，该方法接受一个温度读数列表，并返回一个只包含非负温度的新列表。请确保在代码片段的开头包含必要的导入。此外，提供一个方法，通过给定的数据点来验证你的解决方案的正确性。

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class TemperatureFilter
{
    public static List<int> FilterNonNegativeTemperatures(List<int> temperatures) {
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;

#<INSERT>

class TemperatureAnalyzerTest
{
    public static List<int> GetUniqueSortedTemperatures(List<int> readings)
    {
        return TemperatureAnalyzer.GetUniqueSortedTemperatures(readings);
    }

    public static int Main(string[] args)
    {
        bool allTestsPassed = true;

        // Test Case 1
        List<int> input1 = new List<int> { 30, 22, 20, 22, 30, 20, 31, 20 };
        List<int> expected1 = new List<int> { 20, 22, 30, 31 };
        List<int> result1 = GetUniqueSortedTemperatures(input1);
        allTestsPassed &= result1.SequenceEqual(expected1);

        // Test Case 2
        List<int> input2 = new List<int> { 15, 15, 15, 15, 15 };
        List<int> expected2 = new List<int> { 15 };
        List<int> result2 = GetUniqueSortedTemperatures(input2);
        allTestsPassed &= result2.SequenceEqual(expected2);

        // Test Case 3
        List<int> input3 = new List<int> { -10, -20, -30, -20, -10, -30 };
        List<int> expected3 = new List<int> { -30, -20, -10 };
        List<int> result3 = GetUniqueSortedTemperatures(input3);
        allTestsPassed &= result3.SequenceEqual(expected3);

        // Test Case 4
        List<int> input4 = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
        List<int> expected4 = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
        List<int> result4 = GetUniqueSortedTemperatures(input4);
        allTestsPassed &= result4.SequenceEqual(expected4);

        if (allTestsPassed)
        {
            Console.WriteLine("All tests passed.");
            return 0;
        }
        else
        {
            Console.WriteLine("Some tests failed.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;
class TemperatureAnalyzer
{
    public static List<int> GetUniqueSortedTemperatures(List<int> readings)
    {
        List<int> uniqueSortedReadings = readings.Distinct().OrderBy(x => x).ToList();
        return uniqueSortedReadings;
    }
    ;
        List<int> expectedOutput = new List<int> { 20, 22, 30, 31 };
        List<int> result = GetUniqueSortedTemperatures(temperatureReadings);
        Console.WriteLine("Unique and Sorted Temperatures: " + String.Join(", ", result));
        Debug.Assert(result.SequenceEqual(expectedOutput), "The method did not return the expected result.");
    }
}

想象一下，你正在进行一个需要分析一组数值数据的项目。具体来说，你的任务是找到以摄氏度记录的一系列温度读数中的不同元素。这些读数是在几天内收集的，由于数据收集过程中的一些故障，其中存在重复的读数。你的目标是编写一个C#方法，该方法接受一个整数温度读数列表，并返回一个仅包含唯一温度的新列表，并按升序排序。这将有助于更清楚地识别温度波动的范围。

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class TemperatureAnalyzer
{
    public static List<int> GetUniqueSortedTemperatures(List<int> readings)
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;

#<INSERT>

class NumberTransformerTest
{
    public static void Main(string[] args)
    {
        var testCases = new Dictionary<List<int>, List<string>>
        {
            { new List<int> { 2, 1, 1, 4, 5, 8, 2, 3 }, new List<string> { "Eight", "Five", "Four", "Three", "Two", "Two", "One", "One" } },
            { new List<int>(), new List<string>() },
            { new List<int> { 1, -1, 55 }, new List<string> { "One" } },
            { new List<int> { 9, 7, 3, 6 }, new List<string> { "Nine", "Seven", "Six", "Three" } },
            { new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, new List<string> { "Nine", "Eight", "Seven", "Six", "Five", "Four", "Three", "Two", "One" } }
        };

        int failedTests = 0;

        foreach (var testCase in testCases)
        {
            var output = NumberTransformer.TransformNumbersToWords(testCase.Key);
            bool isCorrect = output.SequenceEqual(testCase.Value);
            Console.WriteLine($"Input: [{string.Join(", ", testCase.Key)}]");
            Console.WriteLine($"Output: [{string.Join(", ", output)}]");
            Console.WriteLine($"Is Correct: {isCorrect}\n");

            if (!isCorrect)
            {
                failedTests++;
            }
        }

        if (failedTests > 0)
        {
            Console.WriteLine($"Failed {failedTests} tests.");
            Environment.Exit(-1);
        }

        Console.WriteLine("All tests passed.");
        Environment.Exit(0);
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;
class NumberTransformer
{
    public static List<string> TransformNumbersToWords(List<int> numbers)
    {
        string[] numberWords = { "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine" };
        List<string> result = numbers
            .Where(n => n >= 1 && n <= 9)
            .OrderBy(n => n)
            .Reverse()
            .Select(n => numberWords[n - 1])
            .ToList();
        return result;
    }
    public static void Check()
    {
        var testCases = new Dictionary<List<int>, List<string>>
        {
            { new List<int> { 2, 1, 1, 4, 5, 8, 2, 3 }, new List<string> { "Eight", "Five", "Four", "Three", "Two", "Two", "One", "One" } },
            { new List<int>(), new List<string>() },
            { new List<int> { 1, -1, 55 }, new List<string> { "One" } }
        };
        foreach (var testCase in testCases)
        {
            var output = TransformNumbersToWords(testCase.Key);
            bool isCorrect = output.SequenceEqual(testCase.Value);
            Console.WriteLine($"Input: [{string.Join(", ", testCase.Key)}]");
            Console.WriteLine($"Output: [{string.Join(", ", output)}]");
            Console.WriteLine($"Is Correct: {isCorrect}\n");
        }
    }
}
class Program
{

}

想象你有一组整数值，并且你需要对这组数据进行特定的转换。你的任务是编写一个 C# 方法，该方法接收一个整数列表并根据以下规则进行处理：

1. 筛选出所有不在 1 到 9 范围内的整数。
2. 将剩余的整数按升序排序。
3. 反转排序后的列表。
4. 将每个整数转换为对应的英文单词表示（1 对应 "One"，2 对应 "Two"，等等）。

例如，如果输入列表是 `[2, 1, 1, 4, 5, 8, 2, 3]`，输出应为 `["Eight", "Five", "Four", "Three", "Two", "Two", "One", "One"]`。如果输入列表为空或没有在 1 到 9 范围内的整数，输出应为空列表。范围外的整数应被忽略。

编写一个名为 `TransformNumbersToWords` 的 C# 方法来实现此功能。此外，包含一个检查函数来使用提供的数据点验证方法的正确性。

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class NumberTransformer
{
    public static List<string> TransformNumbersToWords(List<int> numbers)
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class TransactionAnalyzerTest {
    public static int Main(string[] args) {
        bool allTestsPassed = true;

        // Test Case 1
        allTestsPassed &= TransactionAnalyzer.HasCancelingTransactions(new List<int>{1, 3, -1, 4}) == true;

        // Test Case 2
        allTestsPassed &= TransactionAnalyzer.HasCancelingTransactions(new List<int>{5, 7, 2}) == false;

        // Test Case 3
        allTestsPassed &= TransactionAnalyzer.HasCancelingTransactions(new List<int>{0, -5, 5, 10}) == true;

        // Test Case 4
        allTestsPassed &= TransactionAnalyzer.HasCancelingTransactions(new List<int>{}) == false;

        // Test Case 5
        allTestsPassed &= TransactionAnalyzer.HasCancelingTransactions(new List<int>{-1, 1, 2, -2, 3, -3}) == true;

        if (allTestsPassed) {
            Console.WriteLine("All tests passed!");
            return 0;
        } else {
            Console.WriteLine("Some tests failed.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class TransactionAnalyzer {
    public static bool HasCancelingTransactions(List<int> transactions) {
        HashSet<int> seen = new HashSet<int>();
        foreach (int amount in transactions) {
            if (seen.Contains(-amount)) {
                return true;
            }
            seen.Add(amount);
        }
        return false;
    }
    public static void Check() {
        Debug.Assert(HasCancelingTransactions(new List<int>{1, 3, -1, 4}) == true);
        Debug.Assert(HasCancelingTransactions(new List<int>{5, 7, 2}) == false);
        Debug.Assert(HasCancelingTransactions(new List<int>{0, -5, 5, 10}) == true);
        Debug.Assert(HasCancelingTransactions(new List<int>{}) == false);
        Console.WriteLine("All checks passed!");
    }

}

想象一下，你正在为金融软件应用开发一个功能，该功能需要快速识别是否有两笔交易互相抵消。具体来说，你的任务是编写一个方法，检查是否有两笔不同的交易金额之和正好为零。例如，这在检测错误或潜在的欺诈活动时可能会很有用。你的方法应该接受一个交易金额列表（以整数表示），并返回 `true`，如果存在至少一对交易金额之和为零；否则返回 `false`。

你能设计一个高效完成此任务的C#方法吗？

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class TransactionAnalyzer
{
    public static bool HasCancelingTransactions(List<int> transactions) {
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;

#<INSERT>

class EmailValidatorTest {
    public static void Main(string[] args) {
        int result = 0;
        var testCases = new List<Tuple<string, string>> {
            Tuple.Create("example@domain.com", "Valid"),
            Tuple.Create("1example@domain.com", "Invalid"),
            Tuple.Create("example@domain.co.uk", "Invalid"),
            Tuple.Create("example@domain.net", "Valid"),
            Tuple.Create("example@domain.org", "Valid")
        };

        foreach (var testCase in testCases) {
            string input = testCase.Item1;
            string expected = testCase.Item2;
            string actual = EmailValidator.ValidateEmail(input);

            if (actual != expected) {
                Console.WriteLine($"Test failed for input: {input}. Expected: {expected}, Actual: {actual}");
                result = -1;
            }
        }

        if (result == 0) {
            Console.WriteLine("All tests passed!");
        } else {
            Console.WriteLine("Some tests failed.");
        }

        Environment.Exit(result);
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;
class EmailValidator {
    public static string ValidateEmail(string email) {
        string[] allowedDomainExtensions = { "com", "net", "org" };
        int atIndex = email.IndexOf('@');
        int dotIndex = email.LastIndexOf('.');
        if (atIndex > 0 && dotIndex > atIndex + 1) {
            string localPart = email.Substring(0, atIndex);
            string domainPart = email.Substring(atIndex + 1, dotIndex - atIndex - 1);
            string domainExtension = email.Substring(dotIndex + 1);
            if (char.IsDigit(localPart[0]) || !allowedDomainExtensions.Contains(domainExtension)) {
                return "Invalid";
            }
            return "Valid";
        }
        return "Invalid";
    }

}

你能写一个 C# 方法来确定所提供的电子邮箱地址是否有效吗？一个电子邮箱被认为是有效的，如果它满足以下所有条件：
- 它恰好包含一个 '@' 符号。
- 本地部分（'@' 前面部分）不能以数字开头，并且必须至少有一个字符长。
- 域部分（'@' 后面部分）必须恰好包含一个点（'.'）。
- 域点后的子字符串必须是 'com'、'net' 或 'org'。
用几个电子邮箱地址测试该函数以验证其正确性。

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class EmailValidator
{
    public static string ValidateEmail(string email) {
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class RhythmParserTest
{
    public static int Main(string[] args)
    {
        List<Tuple<string, List<double>>> testCases = new List<Tuple<string, List<double>>>
        {
            Tuple.Create("x x- *- x- x-", new List<double> { 1.0, 0.5, 0.25, 0.5, 0.5 }),
            Tuple.Create("x x x- *-", new List<double> { 1.0, 1.0, 0.5, 0.25 }),
            Tuple.Create("*-*- x", new List<double> { 0.25, 0.25, 1.0 }),
            Tuple.Create("x- x- x-", new List<double> { 0.5, 0.5, 0.5 }),
            Tuple.Create("x *-", new List<double> { 1.0, 0.25 })
        };

        int failedTests = 0;

        foreach (var testCase in testCases)
        {
            List<double> result = RhythmParser.ParseRhythms(testCase.Item1);
            if (!result.SequenceEqual(testCase.Item2))
            {
                Console.WriteLine($"Test failed for input '{testCase.Item1}': Expected {string.Join(", ", testCase.Item2)} but got {string.Join(", ", result)}");
                failedTests++;
            }
        }

        if (failedTests > 0)
        {
            return -1;
        }

        Console.WriteLine("All tests passed.");
        return 0;
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class RhythmParser
{
    public static List<double> ParseRhythms(string rhythmString)
    {
        List<double> durations = new List<double>();
        for (int i = 0; i < rhythmString.Length; i++)
        {
            switch (rhythmString[i])
            {
                case 'x':
                    if (i + 1 < rhythmString.Length && rhythmString[i + 1] == '-')
                    {
                        durations.Add(0.5);
                        i++;
                    }
                    else
                    {
                        durations.Add(1.0);
                    }
                    break;
                case '*':
                    if (i + 1 < rhythmString.Length && rhythmString[i + 1] == '-')
                    {
                        durations.Add(0.25);
                        i++;
                    }
                    break;
            }
        }
        return durations;
    }

    }
}

想象一下，你正在开发一个音乐教育应用程序的功能，帮助用户理解节奏模式。你需要编写一个函数，该函数解释表示不同节奏值的ASCII艺术字符串，并将其转换为持续时间列表。字符串中的每个字符或字符组合表示特定的音符时值：

- 'x' 代表四分音符，持续1拍。
- 'x-' 代表八分音符，持续半拍。
- '*-' 表示十六分音符，持续四分之一拍。

给定一个由这些字符组成的字符串，你的任务是解析它并返回一个双精度数列表，其中每个元素表示相应音符的持续时间（以拍为单位）。例如，如果输入字符串是 "x x- *- x- x-"，输出应该是包含 [1.0, 0.5, 0.25, 0.5, 0.5] 这些值的列表。

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class RhythmParser
{
    public static List<double> ParseRhythms(string rhythmString)
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class RhythmParserTest {
    public static int Main(string[] args) {
        // Test cases
        var testCases = new List<Tuple<string, List<int>>> {
            Tuple.Create("X X| - X| X| - - - X X", new List<int> { 4, 2, 1, 2, 2, 1, 1, 1, 4, 4 }),
            Tuple.Create("X X| - -", new List<int> { 4, 2, 1, 1 }),
            Tuple.Create("X| X - X| -", new List<int> { 2, 4, 1, 2, 1 }),
            Tuple.Create("X X X", new List<int> { 4, 4, 4 }),
            Tuple.Create("- - - -", new List<int> { 1, 1, 1, 1 })
        };

        bool allTestsPassed = true;
        foreach (var testCase in testCases) {
            var result = RhythmParser.ParseRhythms(testCase.Item1);
            if (!result.SequenceEqual(testCase.Item2)) {
                Console.WriteLine($"Test failed for input: {testCase.Item1}");
                Console.WriteLine($"Expected: [{string.Join(", ", testCase.Item2)}]");
                Console.WriteLine($"Actual: [{string.Join(", ", result)}]");
                allTestsPassed = false;
            }
        }

        if (allTestsPassed) {
            Console.WriteLine("All tests passed.");
            return 0;
        } else {
            Console.WriteLine("Some tests failed.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class RhythmParser {
    public static List<int> ParseRhythms(string rhythm) {
        List<int> beats = new List<int>();
        int i = 0;
        while (i < rhythm.Length) {
            if (rhythm[i] == 'X') {
                if (i + 1 < rhythm.Length && rhythm[i + 1] == '|') {
                    beats.Add(2);
                    i += 2;
                } else {
                    beats.Add(4);
                    i++;
                }
            } else if (rhythm[i] == '-') {
                beats.Add(1);
                i++;
            } else {
                i++;
            }
        }
        return beats;
    }
    ]");
    }
}

想象一下，你正在为一个音乐教育应用程序开发一个功能，该功能教用户理解乐谱的节奏。应用程序需要一种方法将节奏的文本表示转换为它们所代表的拍数。每个节奏在字符串中由特定的字符模式表示。你的任务是创建一个函数，该函数接受一个节奏模式的字符串并返回一个整数列表，其中每个整数代表每个节奏模式的拍数。使用以下字符模式：

- `'X'` 代表全音符，持续四拍。
- `'X|'` 代表二分音符，持续两拍。
- `'-'` 代表四分音符，持续一拍。

例如，如果输入字符串是 `"X X| - X| X| - - - X X"`，你的函数应该返回对应于拍数的整数列表：`[4, 2, 1, 2, 2, 1, 1, 1, 4, 4]`。

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class RhythmParser
{
    public static List<int> ParseRhythms(string rhythm) {
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class FinancialAnalyzerTest
{
    public static int Main(string[] args)
    {
        bool allTestsPassed = true;

        // Test Case 1
        List<long> test1 = new List<long> { 2, 3, 4, 1, 2, 4 };
        long result1 = FinancialAnalyzer.FindLeastProfitablePeriod(test1);
        if (result1 != 1)
        {
            Console.WriteLine($"Test 1 Failed: Expected 1, Got {result1}");
            allTestsPassed = false;
        }

        // Test Case 2
        List<long> test2 = new List<long> { -1, -2, -3 };
        long result2 = FinancialAnalyzer.FindLeastProfitablePeriod(test2);
        if (result2 != -6)
        {
            Console.WriteLine($"Test 2 Failed: Expected -6, Got {result2}");
            allTestsPassed = false;
        }

        // Test Case 3
        List<long> test3 = new List<long> { 100, 200, -500, 300, 100, -400, 200 };
        long result3 = FinancialAnalyzer.FindLeastProfitablePeriod(test3);
        if (result3 != -500)
        {
            Console.WriteLine($"Test 3 Failed: Expected -500, Got {result3}");
            allTestsPassed = false;
        }

        // Test Case 4
        List<long> test4 = new List<long> { 5, -1, -2, 3, -4, 2, 1 };
        long result4 = FinancialAnalyzer.FindLeastProfitablePeriod(test4);
        if (result4 != -4)
        {
            Console.WriteLine($"Test 4 Failed: Expected -4, Got {result4}");
            allTestsPassed = false;
        }

        // Test Case 5
        List<long> test5 = new List<long> { 1, 2, 3, 4, 5 };
        long result5 = FinancialAnalyzer.FindLeastProfitablePeriod(test5);
        if (result5 != 1)
        {
            Console.WriteLine($"Test 5 Failed: Expected 1, Got {result5}");
            allTestsPassed = false;
        }

        if (allTestsPassed)
        {
            Console.WriteLine("All tests passed!");
            return 0;
        }
        else
        {
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class FinancialAnalyzer
{
    public static long FindLeastProfitablePeriod(List<long> transactions)
    {
        if (transactions == null || transactions.Count == 0)
        {
            throw new ArgumentException("The transactions list cannot be null or empty.");
        }
        long minSum = transactions[0], currentSum = transactions[0];
        for (int i = 1; i < transactions.Count; i++)
        {
            currentSum = Math.Min(transactions[i], currentSum + transactions[i]);
            minSum = Math.Min(minSum, currentSum);
        }
        return minSum;
    }
    ));
        Console.WriteLine(FindLeastProfitablePeriod(new List<long> { -1, -2, -3 }));
        Console.WriteLine(FindLeastProfitablePeriod(new List<long> { 100, 200, -500, 300, 100, -400, 200 }));
    }
}

想象一下，你正在编写一个需要处理大量日常交易金额数据的财务分析工具。你的任务是编写一个 C# 方法来查找任何连续交易序列的最小可能和。例如，这可以用于识别最不盈利的时间段。该方法应接受一个表示日常交易金额的整数列表，并返回任何连续子序列的最小和。

例如，如果你有一周的交易记录，如 `[100, 200, -500, 300, 100, -400, 200]`，该方法应识别出和最小的时间段（在这种情况下，`-500 + 300 + 100 - 400 = -500`）。注意，交易金额也可能全为正数或全为负数。

你能写一个高效完成此任务的 C# 方法吗？

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class FinancialAnalyzer
{
    public static long FindLeastProfitablePeriod(List<long> transactions)
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;

#<INSERT>

class DigitSumCalculatorTest {
    public static int Main(string[] args) {
        bool allTestsPassed = true;

        // Test Case 1
        if (DigitSumCalculator.SumLastDigits(123, 456) != 9) {
            Console.WriteLine("Test 1 Failed");
            allTestsPassed = false;
        } else {
            Console.WriteLine("Test 1 Passed");
        }

        // Test Case 2
        if (DigitSumCalculator.SumLastDigits(-97, 32) != 9) {
            Console.WriteLine("Test 2 Failed");
            allTestsPassed = false;
        } else {
            Console.WriteLine("Test 2 Passed");
        }

        // Test Case 3
        if (DigitSumCalculator.SumLastDigits(1000, -300) != 0) {
            Console.WriteLine("Test 3 Failed");
            allTestsPassed = false;
        } else {
            Console.WriteLine("Test 3 Passed");
        }

        // Test Case 4
        if (DigitSumCalculator.SumLastDigits(-15, -25) != 10) {
            Console.WriteLine("Test 4 Failed");
            allTestsPassed = false;
        } else {
            Console.WriteLine("Test 4 Passed");
        }

        // Test Case 5
        if (DigitSumCalculator.SumLastDigits(0, 0) != 0) {
            Console.WriteLine("Test 5 Failed");
            allTestsPassed = false;
        } else {
            Console.WriteLine("Test 5 Passed");
        }

        return allTestsPassed ? 0 : -1;
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;
class DigitSumCalculator {
    public static int SumLastDigits(int num1, int num2) {
        int lastDigit1 = Math.Abs(num1) % 10;
        int lastDigit2 = Math.Abs(num2) % 10;
        int sum = lastDigit1 + lastDigit2;
        return sum;
    }
    public static void Check() {
        Console.WriteLine(SumLastDigits(123, 456) == 9 ? "Test 1 Passed" : "Test 1 Failed");
        Console.WriteLine(SumLastDigits(-97, 32) == 9 ? "Test 2 Passed" : "Test 2 Failed");
        Console.WriteLine(SumLastDigits(1000, -300) == 0 ? "Test 3 Passed" : "Test 3 Failed");
        Console.WriteLine(SumLastDigits(-15, -25) == 10 ? "Test 4 Passed" : "Test 4 Failed");
    }

}

想象你正在处理一个软件项目，需要设计一个函数来确定任何两个给定的正整数或负整数的最后一位数之和。这项任务对于金融应用中的一个功能至关重要，因为交易通常需要基于货币的最小面值进行计算。你的挑战是编写一个独立的 C# 代码片段，包括所有必要的导入，遵循最佳实践，并且易于理解。该函数应接受两个整数作为输入，并返回它们最后一位数的和。例如，如果函数接收数字 123 和 456，则应返回 9，因为 123 的最后一位数（3）加上 456 的最后一位数（6）等于 9。确保你的解决方案高效，并能优雅地处理正数和负数。

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class DigitSumCalculator
{
    public static int SumLastDigits(int num1, int num2) {
    {
        // Implement your code here.
    }
}
```


using System;

#<INSERT>

public class FinancialCalculatorTest
{
    public static int Main(string[] args)
    {
        bool allTestsPassed = true;

        allTestsPassed &= TestGetCents(123.45f, 45f);
        allTestsPassed &= TestGetCents(99.99f, 99f);
        allTestsPassed &= TestGetCents(0.01f, 1f);
        allTestsPassed &= TestGetCents(100.00f, 0f);
        allTestsPassed &= TestGetCents(250.75f, 75f);

        return allTestsPassed ? 0 : -1;
    }

    private static bool TestGetCents(float input, float expected)
    {
        FinancialCalculator calculator = new FinancialCalculator();
        float result = calculator.GetCents(input);

        if (Math.Abs(result - expected) < 0.01f)
        {
            Console.WriteLine($"Test passed for input: {input}");
            return true;
        }
        else
        {
            Console.WriteLine($"Test failed for input: {input}. Expected: {expected}, but got: {result}");
            return false;
        }
    }
}

public class FinancialCalculator
{
    /// <summary>
    /// This method separates the cents from a given amount of money in dollars.
    /// </summary>
    /// <param name="amount">The amount in dollars and cents</param>
    /// <returns>The cents as a separate floating-point number</returns>
    public float GetCents(float amount)
    {
        // Get the fractional part of the amount
        float fractionalPart = amount - (int)amount;

        // Convert the fractional part to cents
        float cents = fractionalPart * 100;

        // Return the cents rounded to two decimal places
        return (float)Math.Round(cents, 2);
    }
}

想象一下，你正在开发一个金融应用程序，其中精确的计算至关重要。你需要编写一个函数，该函数可以从给定的美元金额中分离出美分。例如，如果你有$123.45，你希望将45美分作为一个单独的浮点数分离出来。你会如何设计一个C#函数来完成这个任务，确保它可以处理任何表示美元和美分的正浮点数？

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class FinancialCalculator
{
public class FinancialCalculator
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class AccountTrackerTest {
    public static int Main(string[] args) {
        bool allTestsPassed = true;

        // Test Case 1
        List<int> transactions1 = new List<int> { 1, 2, 3 };
        bool result1 = AccountTracker.DetectOverdraft(transactions1);
        if (result1 != false) {
            Console.WriteLine("Test Case 1 Failed");
            allTestsPassed = false;
        }

        // Test Case 2
        List<int> transactions2 = new List<int> { 1, 2, -4, 5 };
        bool result2 = AccountTracker.DetectOverdraft(transactions2);
        if (result2 != true) {
            Console.WriteLine("Test Case 2 Failed");
            allTestsPassed = false;
        }

        // Test Case 3
        List<int> transactions3 = new List<int> { -1, -2, 4, -5, 6 };
        bool result3 = AccountTracker.DetectOverdraft(transactions3);
        if (result3 != true) {
            Console.WriteLine("Test Case 3 Failed");
            allTestsPassed = false;
        }

        // Test Case 4
        List<int> transactions4 = new List<int> { 10, -5, -3, -2 };
        bool result4 = AccountTracker.DetectOverdraft(transactions4);
        if (result4 != false) {
            Console.WriteLine("Test Case 4 Failed");
            allTestsPassed = false;
        }

        // Test Case 5
        List<int> transactions5 = new List<int> { -10, 5, 5 };
        bool result5 = AccountTracker.DetectOverdraft(transactions5);
        if (result5 != true) {
            Console.WriteLine("Test Case 5 Failed");
            allTestsPassed = false;
        }

        if (allTestsPassed) {
            Console.WriteLine("All tests passed.");
            return 0;
        } else {
            Console.WriteLine("Some tests failed.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class AccountTracker {
    public static bool DetectOverdraft(List<int> transactions) {
        int balance = 0;
        foreach (var transaction in transactions) {
            balance += transaction;
            if (balance < 0) {
                return true;
            }
        }
        return false;
    }
    public ));
        Console.WriteLine(DetectOverdraft(new List<int>{1, 2, -4, 5}));
        Console.WriteLine(DetectOverdraft(new List<int>{-1, -2, 4, -5, 6}));
    }
}

假设您正在开发一个需要跟踪用户账户在一系列交易中的余额的财务应用程序。每笔交易可以是存款（正值）或取款（负值）。账户从零余额开始。您的任务是编写一个方法，该方法遍历这些交易列表，并确定账户的余额是否在任何时刻跌破零。如果余额跌破零，该方法应返回`true`，表明账户出现了透支。如果在所有交易中余额从未跌破零，则该方法应返回`false`。

您能编写一个实现此功能的C#方法吗？请确保包括必要的导入，并使用提供的数据点创建一个包含检查函数的独立代码段。

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class AccountTracker
{
    public ));
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Text.RegularExpressions;

#<INSERT>

class EmailValidationTest {
    public static int Main(string[] args) {
        bool allTestsPassed = true;

        // Test Case 1
        string result1 = EmailValidation.EmailValidator("example.email@domain.com");
        if (result1 != "Valid") {
            Console.WriteLine("Test Case 1 Failed");
            allTestsPassed = false;
        }

        // Test Case 2
        string result2 = EmailValidation.EmailValidator("_example@domain.com");
        if (result2 != "Invalid") {
            Console.WriteLine("Test Case 2 Failed");
            allTestsPassed = false;
        }

        // Test Case 3
        string result3 = EmailValidation.EmailValidator("example@domain.ccom");
        if (result3 != "Invalid") {
            Console.WriteLine("Test Case 3 Failed");
            allTestsPassed = false;
        }

        // Test Case 4
        string result4 = EmailValidation.EmailValidator("example@domain.com");
        if (result4 != "Valid") {
            Console.WriteLine("Test Case 4 Failed");
            allTestsPassed = false;
        }

        // Test Case 5
        string result5 = EmailValidation.EmailValidator("example@domain..com");
        if (result5 != "Invalid") {
            Console.WriteLine("Test Case 5 Failed");
            allTestsPassed = false;
        }

        if (allTestsPassed) {
            Console.WriteLine("All tests passed.");
            return 0;
        } else {
            Console.WriteLine("Some tests failed.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Text.RegularExpressions;
class EmailValidation {
    public static string EmailValidator(string email) {
        string pattern = @"^[a-zA-Z][a-zA-Z0-9._]*@[a-z]+\.(com|net|org)$";
        if (Regex.IsMatch(email, pattern)) {
            int atCount = email.Count(f => f == '@');
            int dotCount = email.Split('@')[1].Count(f => f == '.');
            if (atCount == 1 && dotCount >= 1) {
                return "Valid";
            }
        }
        return "Invalid";
    }

}

你能写一个方法，根据特定条件检查一个电子邮件地址是否合法吗？该方法应接受一个表示电子邮件地址的字符串，如果电子邮件地址符合所有条件，则返回“Valid”，否则返回“Invalid”。有效电子邮件地址的条件如下：
- 必须包含且仅包含一个 '@' 符号。
- 本地部分（'@' 前）必须以字母（大写或小写）开头，并且可以包含字母、数字、点（'.'）和下划线（ '_'），但不能以点或下划线开头。
- 域部分（'@' 后）必须包含至少一个点（'.'），且域的最后一部分（最后一个点后）必须是 'com'，'net' 或 'org'。
- 域部分在最后一个点之前只能包含小写字母。

 以下是你的方法应如何工作的示例：
```csharp
// 示例用法
Console.WriteLine(EmailValidator("example.email@domain.com")); // 输出: "Valid"
Console.WriteLine(EmailValidator("invalid-email@domain.com")); // 输出: "Invalid"
```

确保你的解决方案包括必要的导入、清晰的方法签名和一个检查函数，并使用提供的数据点验证你的解决方案的正确性。

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class EmailValidation
{
    public static string EmailValidator(string email) {
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class MusicDurationParserTest
{
    public static int Main(string[] args)
    {
        bool allTestsPassed = true;

        // Test Case 1
        List<int> result1 = MusicDurationParser.ConvertNoteDurations("W H- Q-");
        List<int> expected1 = new List<int> { 4, 2, 1 };
        if (!result1.SequenceEqual(expected1))
        {
            Console.WriteLine("Test Case 1 Failed");
            allTestsPassed = false;
        }

        // Test Case 2
        List<int> result2 = MusicDurationParser.ConvertNoteDurations("Q- Q- Q- Q-");
        List<int> expected2 = new List<int> { 1, 1, 1, 1 };
        if (!result2.SequenceEqual(expected2))
        {
            Console.WriteLine("Test Case 2 Failed");
            allTestsPassed = false;
        }

        // Test Case 3
        List<int> result3 = MusicDurationParser.ConvertNoteDurations("W W W");
        List<int> expected3 = new List<int> { 4, 4, 4 };
        if (!result3.SequenceEqual(expected3))
        {
            Console.WriteLine("Test Case 3 Failed");
            allTestsPassed = false;
        }

        // Test Case 4
        List<int> result4 = MusicDurationParser.ConvertNoteDurations("H- H- H- H-");
        List<int> expected4 = new List<int> { 2, 2, 2, 2 };
        if (!result4.SequenceEqual(expected4))
        {
            Console.WriteLine("Test Case 4 Failed");
            allTestsPassed = false;
        }

        // Test Case 5
        List<int> result5 = MusicDurationParser.ConvertNoteDurations("W H- Q- H- H- Q- Q- Q- Q- W W");
        List<int> expected5 = new List<int> { 4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4 };
        if (!result5.SequenceEqual(expected5))
        {
            Console.WriteLine("Test Case 5 Failed");
            allTestsPassed = false;
        }

        if (allTestsPassed)
        {
            Console.WriteLine("All tests passed.");
            return 0;
        }
        else
        {
            Console.WriteLine("Some tests failed.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class MusicDurationParser
{
    public static List<int> ConvertNoteDurations(string notes)
    {
        List<int> durations = new List<int>();
        string[] noteArray = notes.Split(' ');
        foreach (string note in noteArray)
        {
            switch (note)
            {
                case "W":
                    durations.Add(4);
                    break;
                case "H-":
                    durations.Add(2);
                    break;
                case "Q-":
                    durations.Add(1);
                    break;
                default:
                    throw new ArgumentException("Unknown note encountered.");
            }
        }
        return durations;
    }
    ;
        List<int> actualDurations = ConvertNoteDurations(testNotes);
        Console.WriteLine($"Expected: {string.Join(", ", expectedDurations)}");
        Console.WriteLine($"Actual: {string.Join(", ", actualDurations)}");
    }
}

想象一下，你正在开发一个音乐教育应用的功能，帮助用户理解音乐作品中不同音符的时值。你的任务是编写一个C#方法，该方法解释由独特的ASCII字符序列表示的音乐音符字符串，并将它们转换为以拍子为单位的相应时值。标记方法如下：

- 'W' 代表全音符，持续四拍。
- 'H' 加上一个破折号 'H-' 代表二分音符，持续两拍。
- 'Q' 加上一个破折号 'Q-' 表示四分音符，持续一拍。

编写一个方法 `ConvertNoteDurations`，该方法接受一个包含这些音符表示的序列的字符串参数，并返回一个整数列表，其中每个整数表示输入字符串中相应音符的拍子时值。

例如，如果输入字符串是 "W H- Q- H- H- Q- Q- Q- Q- W W"，则该方法应返回一个整数列表，对应每个音符的拍子时值:`[4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]`。

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class MusicDurationParser
{
    public static List<int> ConvertNoteDurations(string notes)
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Linq;

#<INSERT>

class StringStrengthEvaluatorTest
{
    public static int Main(string[] args)
    {
        bool allTestsPassed = true;

        // Test case 1
        if (StringStrengthEvaluator.CalculateUppercaseAsciiSum("") != 0)
        {
            Console.WriteLine("Test case 1 failed.");
            allTestsPassed = false;
        }

        // Test case 2
        if (StringStrengthEvaluator.CalculateUppercaseAsciiSum("abAB") != 131)
        {
            Console.WriteLine("Test case 2 failed.");
            allTestsPassed = false;
        }

        // Test case 3
        if (StringStrengthEvaluator.CalculateUppercaseAsciiSum("abcCd") != 67)
        {
            Console.WriteLine("Test case 3 failed.");
            allTestsPassed = false;
        }

        // Test case 4
        if (StringStrengthEvaluator.CalculateUppercaseAsciiSum("helloE") != 69)
        {
            Console.WriteLine("Test case 4 failed.");
            allTestsPassed = false;
        }

        // Test case 5
        if (StringStrengthEvaluator.CalculateUppercaseAsciiSum("woArBld") != 131)
        {
            Console.WriteLine("Test case 5 failed.");
            allTestsPassed = false;
        }

        if (allTestsPassed)
        {
            Console.WriteLine("All test cases passed.");
            return 0;
        }
        else
        {
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Linq;
class StringStrengthEvaluator
{
    public static long CalculateUppercaseAsciiSum(string input)
    {
        return input.Where(char.IsUpper).Sum(c => (long)c);
    }

}

想象一下，你在开发一个安全应用程序，需要根据字符串中的大写字符来分析它们的强度。你的任务是编写一个C#方法，通过计算字符串中所有大写字母的ASCII值之和来评估给定字符串的强度。该方法应返回表示此和的`long`值。

以下是该方法的要求：

- 方法应名为 `CalculateUppercaseAsciiSum`。
- 它应接受一个 `string` 参数。
- 它应返回一个 `long` 值，表示输入字符串中所有大写字符的ASCII值之和。
- 如果字符串不包含任何大写字符，方法应返回 `0`。

例如，如果输入字符串是 `"HelloWorld"`，方法应返回 `'H'`、`'W'`和`'D'`的ASCII值之和。

编写一个包含该方法以及一个用提供的数据点来验证方法正确性的检查函数的独立代码片段。

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class StringStrengthEvaluator
{
    public static long CalculateUppercaseAsciiSum(string input)
    {
        // Implement your code here.
    }
}
```


using System;

#<INSERT>

public class FinancialDataAnalyzerTest
{
    public static int Main()
    {
        FinancialDataAnalyzer analyzer = new FinancialDataAnalyzer();
        bool allTestsPassed = true;

        // Test Case 1: Regular case with mixed positive and negative values
        int[] testCase1 = { 2, 3, -6, 4, 2 };
        int expected1 = -6;
        allTestsPassed &= (analyzer.FindMinimumSumOfContiguousSubsequence(testCase1) == expected1);

        // Test Case 2: All positive values
        int[] testCase2 = { 1, 2, 3, 4, 5 };
        int expected2 = 1;
        allTestsPassed &= (analyzer.FindMinimumSumOfContiguousSubsequence(testCase2) == expected2);

        // Test Case 3: All negative values
        int[] testCase3 = { -1, -2, -3, -4, -5 };
        int expected3 = -15;
        allTestsPassed &= (analyzer.FindMinimumSumOfContiguousSubsequence(testCase3) == expected3);

        // Test Case 4: Mixed values with the minimum sum in the middle
        int[] testCase4 = { 3, -4, 2, -3, -1, 4, -5 };
        int expected4 = -5;
        allTestsPassed &= (analyzer.FindMinimumSumOfContiguousSubsequence(testCase4) == expected4);

        // Test Case 5: Single element array
        int[] testCase5 = { -10 };
        int expected5 = -10;
        allTestsPassed &= (analyzer.FindMinimumSumOfContiguousSubsequence(testCase5) == expected5);

        return allTestsPassed ? 0 : -1;
    }
}

public class FinancialDataAnalyzer
{
    public int FindMinimumSumOfContiguousSubsequence(int[] dailySpending)
    {
        if (dailySpending == null || dailySpending.Length == 0)
        {
            throw new ArgumentException("The daily spending array must not be null or empty.");
        }

        int minSum = dailySpending[0];
        int currentSum = dailySpending[0];

        for (int i = 1; i < dailySpending.Length; i++)
        {
            currentSum = Math.Min(dailySpending[i], currentSum + dailySpending[i]);
            minSum = Math.Min(minSum, currentSum);
        }

        return minSum;
    }
}

想象一下，你正在进行一个涉及分析财务数据的项目。你需要找到花费最低的时间段，即使这意味着查看单独的日子。为了解决这个问题，你需要编写一个C#方法，该方法计算每日花费金额数组（可能是正数或负数）中连续子序列的最小可能和。你如何设计一个方法，该方法接收一个表示每日花费的整数数组，并返回任何连续子序列的最小和？例如，如果给定一个[2, 3, -6, 4, 2]的数组，该方法应该返回-6，因为选择子序列[-6]会得到最小的和。

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class FinancialDataAnalyzer
{
public class FinancialDataAnalyzer
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class FinancialAnalyzerTest
{
    public static int Main()
    {
        bool allTestsPassed = true;

        // Test Case 1
        var result1 = FinancialAnalyzer.CalculateSumAndProduct(new List<int> { 5, 20, 10 });
        if (result1.Item1 != 35 || result1.Item2 != 1000)
        {
            Console.WriteLine("Test Case 1 Failed");
            allTestsPassed = false;
        }

        // Test Case 2
        var result2 = FinancialAnalyzer.CalculateSumAndProduct(new List<int>());
        if (result2.Item1 != 0 || result2.Item2 != 1)
        {
            Console.WriteLine("Test Case 2 Failed");
            allTestsPassed = false;
        }

        // Test Case 3
        var result3 = FinancialAnalyzer.CalculateSumAndProduct(new List<int> { 1, 2, 3, 4 });
        if (result3.Item1 != 10 || result3.Item2 != 24)
        {
            Console.WriteLine("Test Case 3 Failed");
            allTestsPassed = false;
        }

        // Test Case 4
        var result4 = FinancialAnalyzer.CalculateSumAndProduct(new List<int> { -1, -2, -3, -4 });
        if (result4.Item1 != -10 || result4.Item2 != 24)
        {
            Console.WriteLine("Test Case 4 Failed");
            allTestsPassed = false;
        }

        // Test Case 5
        var result5 = FinancialAnalyzer.CalculateSumAndProduct(new List<int> { 0, 0, 0 });
        if (result5.Item1 != 0 || result5.Item2 != 0)
        {
            Console.WriteLine("Test Case 5 Failed");
            allTestsPassed = false;
        }

        if (allTestsPassed)
        {
            Console.WriteLine("All tests passed.");
            return 0;
        }
        else
        {
            Console.WriteLine("Some tests failed.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class FinancialAnalyzer
{
    public static Tuple<int, int> CalculateSumAndProduct(List<int> stockPrices)
    {
        if (stockPrices == null || stockPrices.Count == 0)
        {
            return Tuple.Create(0, 1);
        }
        int sum = 0;
        int product = 1;
        foreach (int price in stockPrices)
        {
            sum += price;
            product *= price;
        }
        return Tuple.Create(sum, product);
    }
    );
        Console.WriteLine($"Sum: {result1.Item1}, Product: {result1.Item2}");
        var result2 = CalculateSumAndProduct(new List<int>());
        Console.WriteLine($"Sum: {result2.Item1}, Product: {result2.Item2}");
    }
}

你正在制作一个金融分析工具，需要一个函数来处理股票价格列表（整数形式），并计算出总和和所有价格的累积乘积。这个函数对于了解整体市场趋势和价格变动的长期影响是至关重要的。如果列表为空，总和应默认为0，累积乘积应默认为1，因为这些分别是加法和乘法的中性元素。你能写一个C#函数来实现这个功能吗？

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class FinancialAnalyzer
{
    public static Tuple<int, int> CalculateSumAndProduct(List<int> stockPrices)
    {
        // Implement your code here.
    }
}
```


using System;

#<INSERT>

public class FinanceUtilityTest
{
    public static int Main()
    {
        bool allTestsPassed = true;

        // Test Case 1: Normal range with largest even number
        if (FinanceUtility.FindLargestEvenNumber(1, 10) != 10)
        {
            allTestsPassed = false;
        }

        // Test Case 2: Range with no even number
        if (FinanceUtility.FindLargestEvenNumber(1, 1) != -1)
        {
            allTestsPassed = false;
        }

        // Test Case 3: Range with start greater than end
        if (FinanceUtility.FindLargestEvenNumber(10, 1) != -1)
        {
            allTestsPassed = false;
        }

        // Test Case 4: Normal range with largest even number being the start
        if (FinanceUtility.FindLargestEvenNumber(4, 7) != 6)
        {
            allTestsPassed = false;
        }

        // Test Case 5: Range with both start and end being the same even number
        if (FinanceUtility.FindLargestEvenNumber(8, 8) != 8)
        {
            allTestsPassed = false;
        }

        return allTestsPassed ? 0 : -1;
    }
}

public class FinanceUtility
{
    public static int FindLargestEvenNumber(int start, int end)
    {
        // Check if the range is valid
        if (start > end)
        {
            return -1;
        }

        // If the end number is even, start from it, otherwise start from the largest even number less than end
        int largestEven = end % 2 == 0 ? end : end - 1;

        // Check if the largest even number is within the range
        if (largestEven < start)
        {
            return -1;
        }

        return largestEven;
    }
}

你正在为一个新的财务应用程序开发一个实用类，该类可帮助用户进行各种计算。需要实现的一个功能是在特定范围内找到最大的偶数。这个范围由两个数字定义：开始值和结束值。你的任务是编写一个方法，接受两个参数`start`和`end`（两者都包含在内），返回该范围内最大的偶数。如果范围内没有偶数，或者开始值大于结束值，则该方法应返回`-1`。

以下是该方法的一些适用场景：
- 用户想知道在其指定的预算范围内能进行的最大的偶数投资金额。
- 在财务报告中计算给定范围内的最大偶数。

确保你的方法高效，并且能优雅地处理边缘情况。

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class FinanceUtility
{
public class FinanceUtility
    {
        // Implement your code here.
    }
}
```


using System;

#<INSERT>

public class FinancialUtilityTest
{
    public static int Main(string[] args)
    {
        bool allTestsPassed = true;

        // Test Case 1
        double testCase1 = 123.456;
        double expected1 = 0.456;
        double result1 = FinancialUtility.ExtractCents(testCase1);
        if (Math.Abs(result1 - expected1) > 0.0001)
        {
            Console.WriteLine($"Test Case 1 Failed: Expected {expected1}, Got {result1}");
            allTestsPassed = false;
        }

        // Test Case 2
        double testCase2 = 0.789;
        double expected2 = 0.789;
        double result2 = FinancialUtility.ExtractCents(testCase2);
        if (Math.Abs(result2 - expected2) > 0.0001)
        {
            Console.WriteLine($"Test Case 2 Failed: Expected {expected2}, Got {result2}");
            allTestsPassed = false;
        }

        // Test Case 3
        double testCase3 = 100.001;
        double expected3 = 0.001;
        double result3 = FinancialUtility.ExtractCents(testCase3);
        if (Math.Abs(result3 - expected3) > 0.0001)
        {
            Console.WriteLine($"Test Case 3 Failed: Expected {expected3}, Got {result3}");
            allTestsPassed = false;
        }

        // Test Case 4
        double testCase4 = 45.1234;
        double expected4 = 0.123;
        double result4 = FinancialUtility.ExtractCents(testCase4);
        if (Math.Abs(result4 - expected4) > 0.0001)
        {
            Console.WriteLine($"Test Case 4 Failed: Expected {expected4}, Got {result4}");
            allTestsPassed = false;
        }

        // Test Case 5
        double testCase5 = 0.0;
        double expected5 = 0.0;
        double result5 = FinancialUtility.ExtractCents(testCase5);
        if (Math.Abs(result5 - expected5) > 0.0001)
        {
            Console.WriteLine($"Test Case 5 Failed: Expected {expected5}, Got {result5}");
            allTestsPassed = false;
        }

        if (allTestsPassed)
        {
            return 0;
        }
        else
        {
            return -1;
        }
    }
}

using System;

public class FinancialUtility
{
    // Method to extract and return the cents part of a monetary value
    public static double ExtractCents(double amount)
    {
        // Calculate the cents part by subtracting the integer part from the original amount
        double cents = amount - Math.Floor(amount);
        return Math.Round(cents, 3); // Round to 3 decimal places for precision
    }
}

想象一下，你正在开发一个对精度要求很高的金融应用程序。你需要编写一个方法，该方法接收一个表示货币值的浮点数，并提取该金额的小数部分。例如，如果你有$123.456，你需要隔离并返回0.456部分。你会如何在C#中设计这样一个方法，确保在代码片段的开头包含所有必要的包？

请用C#实现不包含Main函数的完整代码，并遵循如下类型定义：
```csharp
using xxx
...
class FinancialUtility
{
public class FinancialUtility
    {
        // Implement your code here.
    }
}
```


import java.util.Arrays;
public class AverageCalculator {
    public static double calculateAverage(int[] numbers) {
        if (numbers == null || numbers.length == 0) {
            throw new IllegalArgumentException("数组不能为空");
        }
        return Arrays.stream(numbers).average().orElse(Double.NaN);
    }
    public static void main(String[] args) {
        int[] testData = {1, 2, 3, 4, 5};
        double average = calculateAverage(testData);
        System.out.println("平均值为: " + average);
        check(calculateAverage(new int[]{10, 20, 30}), 20.0);
        check(calculateAverage(new int[]{5, 5, 5, 5}), 5.0);
        check(calculateAverage(new int[]{1, -1, 3, -3, 5, -5}), 0.0);
    }
    private static void check(double actual, double expected) {
        if (Math.abs(actual - expected) < 0.0001) {
            System.out.println("测试通过");
        } else {
            System.out.println("测试失败: 期望 " + expected + ", 实际 " + actual);
        }
    }
}

编写一个Java程序，用于计算一组数据的平均值。请确保你的程序能够接受一个整型数组作为输入，并返回这组数据的平均值。为了验证你的程序，你需要实现一个名为`calculateAverage`的方法，该方法接受一个`int[]`类型的参数，并返回一个`double`类型的结果，代表输入数组的平均值。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.Arrays;
public class AverageCalculator {
    public static double calculateAverage(int[] numbers) {
    }
}
```

Question: Write a piece of python code to achieve the following function.
Find the maximum perfect square number that is less than the nth Fibonacci number.
The function's name is max_square_number, and the input is an integer n.

Answer:
```python
def max_square_number(n):
 if n <= 2:
 return 0 # For the first two numbers in the Fibonacci sequence, no complete square numbers can be used.

 fibs = [0, 1] # Store the first two numbers of the Fibonacci sequence
 squares = [] # Store the list of perfect square numbers

 max_square = 0
 i = 2

 while i <= n:
 fibs.append(fibs[i-1] + fibs[i-2]) # Calculate the next Fibonacci number
 i += 1

 fib = fibs[-1]
 perfect_squares = [i**2 for i in range(1, int(math.sqrt(fib)) + 1)]
 max_square = max(filter(lambda x: x < fib, perfect_squares))
 return max_square
```

----------------

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class AverageCalculatorTest {
    @Test
    public void testCalculateAverage_withValidInput() {
        int[] numbers = {1, 2, 3, 4, 5};
        double result = AverageCalculator.calculateAverage(numbers);
        assertEquals(3.0, result, 0.0001);
    }
    @Test
    public void testCalculateAverage_withNegativeNumbers() {
        int[] numbers = {1, -1, 3, -3, 5, -5};
        double result = AverageCalculator.calculateAverage(numbers);
        assertEquals(0.0, result, 0.0001);
    }
    @Test
    public void testCalculateAverage_withEmptyArray() {
        int[] numbers = {};
        assertThrows(IllegalArgumentException.class, () -> {
            AverageCalculator.calculateAverage(numbers);
        });
    }
    @Test
    public void testCalculateAverage_withNullArray() {
        assertThrows(IllegalArgumentException.class, () -> {
            AverageCalculator.calculateAverage(null);
        });
    }
    @Test
    public void testCalculateAverage_withSameNumbers() {
        int[] numbers = {5, 5, 5, 5};
        double result = AverageCalculator.calculateAverage(numbers);
        assertEquals(5.0, result, 0.0001);
    }
}