Friday, March 28, 2008
The params keyword defines an optional array of a variable number of arguments (parameters). There can be only one argument with the params keyword, and it must appear at the end of the argument list. Also, the params keyword must describe a single-dimension array.
Wednesday, March 26, 2008
1. Get instance of PageRequestManager
2. Callback function:
function endRequestHandler(sender, eventArgs)
if (eventArgs.get_error() != undefined && eventArgs.get_error().httpStatusCode == '500')
var error Message = eventArgs.get_error().message;
Sunday, March 23, 2008
Saturday, March 22, 2008
Step 1: Declare the System.Net.Mail namespace
Step 2: Create a MailMessage object. This class contains the actual message you want to send. There are four overloaded constructors provided in this class. We will be using
The constructor of this MailMessage class is used to specify the sender email, receiver email, subject, body.
Step 3: To add an attachment to the message, use the Attachment class.
Step 4:After creating a message, use the SmtpClient to send the email to the specified SMTP server. I will be using ‘localhost’ as the SMTP server.
That’s it. It’s that simple.
To configure SMTP configuration data for ASP.NET, you would add the following tags to your web.config file.
Tuesday, March 18, 2008
To set it up, click Tools, then External Tools..., then click Add. Now enter the following data:
Title: Windows Explorer
Leave Initial directoy blank, and click OK. Now when you click Tools, Windows Explorer, Windows Explorer will open with the current file you are editing selected.
Thursday, March 6, 2008
- Intro to Windows Workflow Foundation (Part 1 of 7): Workflow in Windows Applications (Level 100)
- Intro to Windows Workflow Foundation (Part 2 of 7): Simple Human Workflow Using E-mail (Level 200)
- Intro to Windows Workflow Foundation (Part 3 of 7): Hosting and Communications Options in Workflow Scenarios (Level 300)
- Intro to Windows Workflow Foundation (Part 4 of 7): Workflow, Messaging, and Services: Developing Distributed Applications with Workflows (Level 300)
- Intro to Windows Workflow Foundation (Part 5 of 7): Developing Event Driven State Machine Workflows (Level 300)
- Intro to Windows Workflow Foundation (Part 6 of 7): Extending Workflow Capabilities with Custom Activities (Level 300)
- Intro to Windows Workflow Foundation (Part 7 of 7): Developing Rules Driven Workflows (Level 300)
Wednesday, March 5, 2008
One way to format C# strings is to add strings together using the plus-sign operator, such as:
This code will correctly produce the desired output but is inefficient and does not scale as well.
The problem is that in C#, strings are immutable. This means that once a string is created, its value cannot be changed. Instead, when you modify a string, a whole new string is created, and a reference to the new string is returned.
Strings are also interned, which means that if the same string is used in multiple places within an application, all references to that string will point to the same unique string instance in memory.
Back to the example. Since strings are immutable, the code above will create a new string for each addition in the expression, resulting in four extra and unnecessary strings every time the code executes:
The first four strings are essentially throw-away strings that will not likely be used again and hence waste memory space and garbage collection cycles.
The correct approach is to use the String.Format method, such as:
If you are just concatenating strings and don't have any special formatting requirements, then String.Concat is even faster:
In our testing, String.Format can be 10-50% faster than string addition, and String.Concat can be 50-500% faster, depending on string length and number of iterations. Both options use less memory and have less impact on garbage collection than string addition.
So why are C# strings immutable? There is a lengthy discussion here and here. But in general, mutable strings would be a nightmare to manage in a multithreaded environment. Also, strings are stored as an array of characters, so modifying a string's length would require allocating a new character array anyway. Finally, mutable strings could pose a security risk by allowing software to modify database and system connection strings on the fly.