mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-22 03:16:08 +00:00
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:
@@ -7,10 +7,10 @@
|
||||
namespace hello_algo.chapter_backtracking;
|
||||
|
||||
public class preorder_traversal_i_compact {
|
||||
static List<TreeNode> res;
|
||||
List<TreeNode> res = [];
|
||||
|
||||
/* 前序遍历:例题一 */
|
||||
static void PreOrder(TreeNode root) {
|
||||
void PreOrder(TreeNode? root) {
|
||||
if (root == null) {
|
||||
return;
|
||||
}
|
||||
@@ -24,12 +24,11 @@ public class preorder_traversal_i_compact {
|
||||
|
||||
[Test]
|
||||
public void Test() {
|
||||
TreeNode root = TreeNode.ListToTree(new List<int?> { 1, 7, 3, 4, 5, 6, 7 });
|
||||
TreeNode? root = TreeNode.ListToTree([1, 7, 3, 4, 5, 6, 7]);
|
||||
Console.WriteLine("\n初始化二叉树");
|
||||
PrintUtil.PrintTree(root);
|
||||
|
||||
// 前序遍历
|
||||
res = new List<TreeNode>();
|
||||
PreOrder(root);
|
||||
|
||||
Console.WriteLine("\n输出所有值为 7 的节点");
|
||||
|
||||
Reference in New Issue
Block a user