Solved

C# Action a = () => {} what is this in vb.net

Posted on 2011-03-02
4
377 Views
Last Modified: 2012-06-27
Hi I got this code

Action a
        = () =>
            {
              //Do something
              }
            };

Is this creating a new thread, and how to do it in VB.net...
0
Comment
Question by:JSW21
4 Comments
 
LVL 8

Assisted Solution

by:crysallus
crysallus earned 100 total points
ID: 35024430
No, its not creating a new thread. It's called a lambda expression. Some reading:

http://msdn.microsoft.com/en-us/library/bb397687.aspx

http://msdn.microsoft.com/en-us/library/018hxwa8.aspx

How to do lambda expressions in VB:

http://msdn.microsoft.com/en-us/library/bb531253.aspx#Y228
0
 
LVL 9

Assisted Solution

by:mayank_joshi
mayank_joshi earned 100 total points
ID: 35024829
0
 
LVL 7

Accepted Solution

by:
vbigham earned 300 total points
ID: 35029519
Here is a direct translation:
 
Dim a As Action = _
                    Sub()
                        ' Do Something '
                    End Sub

' You can invoke the code inside the Sub() by calling the actions Invoke method. '
a.Invoke()

Open in new window

0
 

Author Closing Comment

by:JSW21
ID: 35213112
Direct translation is making lots of sense.
Thanks,
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now