.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Pattern for parsing function parameters

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :WPF

I need to switch the order of some function parameters. Example:

SubrutineA(p1 + 2, funksjonB(fp1, fp2), p3)

should be

SubrutineA(funksjonB(fp1, fp2), p3, p1 + 2)

This is what I have tried:

string sinput = "SubrutineA(p1 + 2, funksjonB(fp1, fp2), p3)";
string spattern = @"SubrutineA\((.+), (.+), (.+)\)";
string result = Regex.Replace(sinput, spattern, @"SubrutineA($2, $3, $1");
Debug.WriteLine("result: "+result);

Obviously, this fails when parameters contain commas.

I have looked into "Balancing Group definitions" at http://msdn.microsoft.com/en-us/library/bs2twtah.aspx#balancing_group_definition, but find it difficult to apply this to my problem.

Any tips?

View Complete Post

More Related Resource Links

How to send parameters to the AJAX callback function


I need to send som parameters to the callback function of my AJAX call, how can i do that:



function DoSomething(id, textbox1)
  AjaxHandler.FindSomethingInDB(id, Callback);

function Callback(result, eventArgs)
  // Here i need to know the value of textbox1 from the function "DoSomething"


encoding function parameters and return values when binaryMessageEncoding is used


Dear All,

I'm creating simple web service that will accept some parameters (such as customer name and file name) and return content of an xml file as a string and WS client will save it on his side. I'm using custom binding with binaryMessageEncoding and httpTransport. The question is if it is possible to have these input parameters as well as returned xml content binary encoded somehow?

Thanks in advance for your help!


Using EXECUTE on dynamic SQL string containing scalar valued function with parameters


I would like to use EXECUTE for calling a scalar valued function as dynamic SQL and for assigning the return value to a variable. This is working fine as long as the scalar valued function does not have parameters. E.g.:



@Result bit, @Function nvarchar(MAX)

Passing parameters to delegate function


I need to convert the following C# code to VB.NET:

        public bool TryGetRewriteMatch(UrlContext url, out RedirectMatch match)
            // NOTE:  Normally this would use regular expression matches, cached database lookups, and/or dictionary lookups, etc.  It is hard coded for demo purposes...
            if (url.Path.StartsWith("/product/", StringComparison.InvariantCultureIgnoreCase))
                int productID = -1;
                if (url.Path.EndsWith("def.html"))
                    productID = 2;
                else if (url.Path.EndsWith("ghi.html"))
                    productID = 3;

                if (productID > 0)

Hosting CLR - Parameters to _MethodInfo Invoke_3 function

Hello, I've done all the steps to successfully obtain an entry point of the in-memory _Assembly which I now need to call.

The function declaration is as follows:

1  HRESULT __stdcall Invoke_3 (  
2         VARIANT obj,  
3         SAFEARRAY * parameters,  
4         VARIANT * pRetVal ) 

I found no docume

Dialogs and ViewModel - Using Tasks as a Pattern

The ViewModel/MVVM pattern continues to gain popularity, with a blog post showing up every so often, and with tweets and retweets popping up even more often :-). At the same time, there are some interesting topics beyond the core pattern that continue to fuel experimentation. A big one amongst those is how should applications use dialogs when using the view model pattern.

The crux of the problem is the desire to keep the view model independent of UI concerns, and ensure it can be tested in a standalone manner, but that often comes to odds when you want the view model to launch a dialog, and/or do some work after the dialog is closed.

Prototype Design Pattern in C#. Vb.NET

Specify the kind of objects to create using a prototypical instance, and create new objects by copying this prototype

Adapter Design Pattern in C#, VB.NET

Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.

Singleton Design Pattern in C#, Vb.NET

Ensure a class has only one instance and provide a global point of access to it.

The Decorator Pattern & Extension Methods

The decorator pattern provides a formal way to add new functionality to an existing type, without sub-classing. First question: What is wrong with classical inheritance? In and of itself, nothing is wrong with the good old Is-A relationship. It is very common to derive a new class from an existing base class in order to override a few virtual members, and add a pinch of new functionality.

Linq: how to share parameters between lambda expressions ?

When using Linq to objects, you will quickly feel the need to pass some parameters from a method to another but it's not so easy because each Linq method is not calling the following one. In a Linq sequence, each method is using the result computed by the previous one. So, local contexts are not visible from one method to another.
The compiler is using two technical different ways to let parameters go out of a method.

Implementing Continuous Scrolling UI Pattern in ASP.NET

When you have numerous records to show, we have to resort to Paging. There is a better alternative to display voluminous data (especially read only data) while providing a better user experience & also making efficient use of server bandwidth - the Continuous Scrolling or Infinite Scrolling UI Pattern. Read on to know more about how to implement Continuous Scrolling UI Pattern in ASP.NET with a GridView.

Factory Pattern in asp.net

The job of the Factory design pattern is to create concrete sub classes. You can see the Factory design pattern used throughout the .NET Framework.

The essence of the Factory Pattern is to "Define an interface for creating an object, but let the subclasses decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses." Factory methods encapsulate the creation of objects. This can be useful if the creation process is very complex, for example if it depends on settings in configuration files or on user input.

Singleton Design Pattern in Asp.net using C#

When we want to make a only one instance of a class and also making sure that there is a global access point to that object then the design pattern we user is called Singleton. The pattern ensures that the class is instantiated only once and that all requests are directed to that one and only object.

The Factory Design Pattern

Software architects generally think in terms of high-level abstractions rather than low-level programming details. Representing a system in terms of high-level abstractions promotes understanding of the system and reduces its perceived complexity. One such set of abstractions is software design patterns. They have been successfully applied in the past to simplify and solve recurring problems in software design.

Abstract Factory Design Pattern (Sample in C# and VB .NET)

An abstract factory provides an interface for creating families of related objects without specifying their concrete classes. Sometimes one wants to construct an instance of one of a suite of classes, deciding between the classes at the time of instantiation. In order to avoid duplicating the decision making everywhere an instance is created, we need a mechanism for creating instances of related classes without necessarily knowing which will be instantiated.

Prototype Pattern-Creational Patterns in C#

The Prototype Pattern approaches the creation of the objects that our client will use by cloning instances from prototypes as required. This achieves the general aim of decoupling the client from the objects that it will use, but also adds some advantages unique to the Prototype pattern.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend