顯示具有 Function 標籤的文章。 顯示所有文章
顯示具有 Function 標籤的文章。 顯示所有文章

2017年7月27日 星期四

C# 找到 呼叫的Function的完整名稱

請參考以下的程式碼
MethodBase method = stackTrace.GetFrame(1).GetMethod();
string methodName = method.Name;
string className = method.ReflectedType.Name;
Console.WriteLine(className + "." + methodName);


How to find FULL name of calling method C#

C# ICommand 執行多個 Function 或加入參數

在 obj => 加入大括號,如下程式碼。

public ICommand ResetProgramCommand { get { if (_resetProgramCommand == null) { _resetProgramCommand = new RelayCommand(obj => {_event.ResetProgramEvent() , _event.UpdateProgramEvent()}, null); } return _resetProgramCommand; } }


如果是加入參數就變成以下這樣
string value = string.empty;
string result = "Success";

public ICommand ResetProgramCommand { get { if (_resetProgramCommand == null) { _resetProgramCommand = new RelayCommand(obj => {_event.ResetProgramEvent(),value = result;}, null); } return _resetProgramCommand; } }