Solved

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

Posted on 2011-03-02
4
386 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Generate Numbers in JQuery file 11 66
parsing JSON help 1 20
Access Schema 6 26
How can I do Unit Testing with Session ? 1 11
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

829 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