.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

Silverlight 4.0 Optional & Named Parameters

Posted By: niqbal     Posted Date: September 03, 2010    Points: 0   Category :ASP.Net
Named & optional parameters are a new C# language feature coming up with .NET FX 4.0 and guess what. it's in Silverlight 4 as well! Optional parameters will come very useful when defining complex APIs where you would usually have to provide several overloads for the same method for it to make sense to wide variety of usages. Let's take a look at this basic example:public void PositionWindow(bool isTopMost, double left = 0, double top = 0, double width = 800, double height = 600){Window window = Application.Current.MainWindow; window.TopMost = isTopMost;window.Left = left; window.Top = top;window.Width = width;window.Height = height;} isTopMost is the only parameter that's required, all other parameter specify their default value, which makes them optional. But what if you wanted to provide the size only and leave the position to be set to defaults? Enter named parameters. The same method above can be called also with:PositionWindow(isTopMost:true, width: 600, height: 200); // named parametersPositionWindow(true, width: 600, height: 200); // naming is optional when positioned rightPositionWindow(true, height: 200, width: 600); // order doesn't matterPositionWindow(height: 200, width: 600, isTopMost: true); // ... even with the required parameters Simple ... Cheers:)

View Complete Post

More Related Resource Links

Optional named parameters work pretty well

Rob has found a use for dynamic: http://blog.wekeroad.com/2010/08/06/flexible-parameters-with-csharp Yay! Let's celebrate! Well, I was a little puzzled because I don't think it quite adds up in the specific example he chose (although please see no aggressiveness here: Rob's a friend; peace!). The idea is to have the same flexibility that a dynamic language can offer in terms of evolution of an API. Here's his original Ruby example: def my_method(args)   thing_one = args["thing1"]   thing_two = args["thing2"] end my_method :thing1 => "value", :thing2 = Time.now The idea, which is quite common in dynamic languages, is that instead of passing a list of predetermined parameters in a specific order, you...(read more)

Optional Parameters - Not taking values when supplied

All, I have a report that takes 2 optional parameters, one int and one datetime. My data tab is set up as follows: CommandType = Text, Parameters has Parameters.Value etc. for both. Report Parameters are allowed NULL value, Default Value is NULL, datatypes are Integer and Datetime as well. This only runs when the parameters are not supplied values, when I enter a date, it does not take it into account, same for the int value. I have run the proc manually to verify that the query is set up correctly, it seems like the values are not being passed? Any help debugging this would be helpful. Thanks.

A better way to reference your wizard steps using named steps

Note: this article uses the plain vanilla but the concepts apply equally well to its popular counterpart .

By far the most common way that I see wizard steps reference in code snippets is by their index.

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.

Serving Silverlight Apps from Windows Mobile

Even if mobile dev is not my every day work, thanks to the .Net Compact Framework, it's still .Net programming.

Here is the scenario:

You come back home, you have a windows mobile phone wifi capable and you want to quickly get access to your phone pictures from your home network.
You just activate the Wifi, run my app and then browse to the provided link from any computer on the network.

.NET 3.5 Adds Named Pipes Support

you want a named pipe server, all you have to do is create some instances of NamedPipeServerStream to handle each client connection. I stole the following code straight from the MSDN documentation.

Building a 3-Tier App with Silverlight 3, .NET RIA Services, and Azure Table Storage

Silverlight 3, .NET RIA Services, and Windows Azure Services Platform makes a 3-tier Cloud application easier to build: Silverlight 3 as presentation tier, .NET RIA services as the business logic and data access tier, and Windows Azure Table as the data storage tier. The sample application in this article demonstrates the architecture with a simple Survey application with all these technologies working together from Windows Azure.

How to Encrypt Query String Parameters in ASP.NET

Encrypt Query String Parameters in ASP.NET.u can send secure data one page another page u can also use query string to encrypt

Silverlight Simple Animation

Silverlight has several built in techniques for animating controls. Many of these technologies are particularly useful for creating simple animations meant to decorate a web page with eye catching movement that draws the reader's attention. In this post I will skip over these decorative technologies, and instead show how to create a simple animation using a technique similar to those used in many games.

Feature available to Silverlight 4 with VS 2010.

In Part I of this article series we have seen some features available to Silverlight 4 with VS 2010. We will continue to explore more in this article.

Silverlight Slideshow Viewer for SharePoint

This series will walk through the Building Blocks that I have created to demonstrate and improve the SharePoint end user experience. I have been using many of these techniques in my developer focused demos for SharePoint 2010 (and in some cases SharePoint 2007). My plan is to use this post series to distribute my code and provide more detail on the why and the how of many of my code samples

Easier Silverlight Development against SharePoint

I have been spending quite a bit of time lately working with Silverlight 3 and SharePoint. One of the first big shifts for me is that Silverlight Development is Client development. Silverlight runs in the browser, but it runs on the client, so no SharePoint Object Model code. You have to access all of the goodness that is SharePoint through its web services.

WPF / Silverlight tutorial: Visibility property and binding

Visibility property is a very powerful and yet often overlooked property available in both WPF and Silverlight. It enables you to set Visibility of certain UIElement objects to different states like: Visible, Collapsed and Hidden (not supported by Silverlight). This tutorial shows you how to use it and how to bind to Visibility property


Getting Started With Silver light

Integrate Reporting Services with Silverlight and RIA Services

One of the most wanted future features in Silverlight is the possibility to create business reports using Reporting Services. In this article, I will show how to use the existing Reporting Services technology with Silverlight and RIA Services combination.

all basic windows controls,wpf controls,silverlight application

here you will find all the information from basic.

view state vs request parameters


If  the view state is the data entered into the form fields then they are supposed to be available in the request parameters or request body. Then why would we need view state for?


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