feat(csharp) .NET 8.0 code migration (#966)

* .net 8.0 migration

* update docs

* revert change

* revert change and update appendix docs

* remove static

* Update binary_search_insertion.cs

* Update binary_search_insertion.cs

* Update binary_search_edge.cs

* Update binary_search_insertion.cs

* Update binary_search_edge.cs

---------

Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
hpstory
2023-11-26 23:18:44 +08:00
committed by GitHub
parent d960c99a1f
commit 56b20eff36
93 changed files with 539 additions and 487 deletions

View File

@@ -8,7 +8,7 @@ namespace hello_algo.chapter_backtracking;
public class subset_sum_i {
/* 回溯算法:子集和 I */
public static void Backtrack(List<int> state, int target, int[] choices, int start, List<List<int>> res) {
void Backtrack(List<int> state, int target, int[] choices, int start, List<List<int>> res) {
// 子集和等于 target 时,记录解
if (target == 0) {
res.Add(new List<int>(state));
@@ -32,18 +32,18 @@ public class subset_sum_i {
}
/* 求解子集和 I */
public static List<List<int>> SubsetSumI(int[] nums, int target) {
List<int> state = new(); // 状态(子集)
List<List<int>> SubsetSumI(int[] nums, int target) {
List<int> state = []; // 状态(子集)
Array.Sort(nums); // 对 nums 进行排序
int start = 0; // 遍历起始点
List<List<int>> res = new(); // 结果列表(子集列表)
List<List<int>> res = []; // 结果列表(子集列表)
Backtrack(state, target, nums, start, res);
return res;
}
[Test]
public void Test() {
int[] nums = { 3, 4, 5 };
int[] nums = [3, 4, 5];
int target = 9;
List<List<int>> res = SubsetSumI(nums, target);
Console.WriteLine("输入数组 nums = " + string.Join(", ", nums) + ", target = " + target);