C# 方法中的this参数
生活随笔
收集整理的這篇文章主要介紹了
C# 方法中的this参数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
用C#的this關鍵字,對Unity中的Transform類進行擴展的一個實例:
public static class GameHelper {public static void FindChildRecursive(this Transform node, string name, ref Transform target){if (!node || string.IsNullOrEmpty(name))return;if (node.name == name)target = node;else{foreach (Transform item in node)FindChildRecursive(item, name, ref target);}}public static void FindChildrenRecursive(this Transform node, string[] names, ref List<Transform> list){if (!node || names == null)return;if (list == null)list = new List<Transform>();int index = Array.FindIndex(names, n => n == node.name);if (index > -1)list.Add(node);foreach (Transform item in node)FindChildrenRecursive(item, names, ref list);} }這里的擴展方法一般用來查找模型具體骨骼。
轉載于:https://www.cnblogs.com/luguoshuai/p/8639680.html
總結
以上是生活随笔為你收集整理的C# 方法中的this参数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 拍拍贷老客户借款被拒
- 下一篇: C#复习笔记(4)--C#3:革新写代码