[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Delegates return value / Delegates does not return value - C#/VB.NET

Posted on 2012-04-08
2
Medium Priority
?
336 Views
Last Modified: 2012-06-27
Hi,

Can you please provide me examples on:

Delegates return value / Delegates does not return value - C#/VB.NET

Thanks
0
Comment
Question by:milani_lucie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 37822377
Could you be a little more specific as to the conditions of your error?

Here's a simple example of a delegate being used to return a value:
Public Class Form1

    Public Delegate Function ReturnReversedString(ByVal input As String) As String

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim msg As String = "Hello World!"

        Dim rrs As New ReturnReversedString(AddressOf ReverseString)
        msg = rrs(msg)
        MessageBox.Show(msg)
    End Sub

    Private Function ReverseString(ByVal input As String) As String
        Dim sb As New System.Text.StringBuilder
        For i As Integer = input.Length - 1 To 0 Step -1
            sb.Append(input.Substring(i, 1))
        Next
        Return sb.ToString
    End Function

End Class

Open in new window

0
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 2000 total points
ID: 37822516
Action and its other generic Equivalents are the ones that return no value
Func and its other generic equivalents are the ones that return value

Its preferred that you use one of them rather than creating your own.

Here are the examples:-
http://www.claassen.net/geek/blog/2007/12/action-func-never-write-another.html
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
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!
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

649 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