The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
Microsoft HoloLens: Course 101E - Ch. 3
can anyone explain this to me:
// Set up a GestureRecognizer to detect Select gestures.
recognizer.TappedEvent += (source, tapCount, ray) =>
{
// Send an OnSelect message to the focused object and its ancestors.
if (FocusedObject != null)
{
FocusedObject.SendMessageUpwards("OnSelect");
}
};
what does this mean:
recognizer.TappedEvent += (source, tapCount, ray) => { }, what is inside (), why there is a "=>" sign?
Best Answers
-
its called a lamda expression, basically short hand for
recognizer.TappedEvent += OnTapped; } private void OnTapped(object source, int tapCount, RayCast ray) { // Send an OnSelect message to the focused object and its ancestors. if (FocusedObject != null) { FocusedObject.SendMessageUpwards("OnSelect"); } }
6 -
james_ashley ✭✭✭✭
What @jboulanger said.
Just to add even more detail, the lambda expression is syntactic sugar for an anonymous method which in turn is a shortcut for a named event handler that allows you to handle an event inline. The values inside the () to the left of the => are your event handler arguments.
For my money, it's one of the most elegant things to come out of C# 3.0.
James Ashley
VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
Microsoft MVP, Freelance HoloLens/MR Developer
www.imaginativeuniversal.com5
Answers
its called a lamda expression, basically short hand for
What @jboulanger said.
Just to add even more detail, the lambda expression is syntactic sugar for an anonymous method which in turn is a shortcut for a named event handler that allows you to handle an event inline. The values inside the () to the left of the => are your event handler arguments.
For my money, it's one of the most elegant things to come out of C# 3.0.
James Ashley
VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
Microsoft MVP, Freelance HoloLens/MR Developer
www.imaginativeuniversal.com