How would you convert this to valid VB.NET?

I found an article on removing whitespace from my markup in ASP.NET MVC, however, when I use the code converter, the "function" is not properly converted

public class WhitespaceFilterAttribute : ActionFilterAttribute

        public override void OnActionExecuting(ActionExecutingContext filterContext)

            var request = filterContext.HttpContext.Request;
            var response = filterContext.HttpContext.Response;

            response.Filter = new WhiteSpaceFilter(response.Filter, s =>
                        s = Regex.Replace(s, @"\s+", " ");
                        s = Regex.Replace(s, @"\s*\n\s*", "\n");
                        s = Regex.Replace(s, @"\s*\>\s*\<\s*", "><");
                        s = Regex.Replace(s, @"<!--(.*?)-->", "");   //Remove comments

                        // single-line doctype must be preserved 
                        var firstEndBracketPosition = s.IndexOf(">");
                        if (firstEndBracketPosition >= 0)
                            s = s.Remove(firstEndBracketPosition, 1);
                            s = s.Insert(firstEndBracketPosition, ">");
                        return s;



This is what gets generated by the Telerik code converter,

    Public Overrides Sub OnActionExecuting(ByVal filterContext As ActionExecutingContext)

        Dim request = filterContext.HttpContext.Request
        Dim response = filterContext.HttpContext.Response

        response.Filter = New WhiteSpaceFilter(response.Filter, Function(s) Do
        s = Regex.Replace(s, "\s+", " ")
        s = Regex.Replace(s, "\s*\n\s*", vbLf)
        s = Regex.Replace(s, "\s*\>\s*\<\s*", "><")
        s = Regex.Replace(s, "<!--(.*?)-->", "")
        'Remove comments 
        ' single-line doctype must be preserved 
        Dim firstEndBracketPosition = s.IndexOf(">")
        If firstEndBracketPosition >= 0 Then
            s = s.Remove(firstEndBracketPosition, 1)
            s = s.Insert(firstEndBracketPosition, ">")
        End If
        Return s
        End Function)

    End Sub

However the Function(s) Do is invalid. I don't know how to pass a function as a parameter in a method.


It is basically a lambda expression in c#. : You need to look at how to do the same in :

You should be using a delegate for this in VB.NET this and this should help you.

Need Your Help

How to print nested struct objects from vector?

c++ vector struct nested

I am working on a program that keeps inventory of vehicles, so I created a struct for it. It also needs to keep a list of the drivers, so I created a nested struct for that. Here's the code:

What's a reasonably-secure, reasonably-portable way to allocate memory for private keys?

c linux unix

I'm looking for a "best practice" for allocating storage for 256-bit private keys. I'm thinking at minimum, keys shouldn't be paged to disk, and there are maybe some other attack vectors to worry ...