Posts tonen met het label C#. Alle posts tonen
Posts tonen met het label C#. Alle posts tonen

donderdag 30 juli 2009

Async webservice method (2.0)

Create a webservice with a method that returns something.



If u create a web reference in visual studio the async methods are automatically created.
Call the webservice async method and attach an eventhandler for methodCompleted event.

dinsdag 28 juli 2009

Rename Files

Get All columns + size and type from a given SQL table

XML XSD validator class

Use this class to validate an xml file against it's xsd schema...

woensdag 25 maart 2009

Ajax And Sharepoint wss 3.0 SP1

first install Asp.net ajax extensions and modify the web.config of your sharepoint site. instructions can be found here: msdn ajax install .

a simpler and safer way to put a scriptmanager is to add it to the masterpage (can be found :C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\TEMPLATE\GLOBAL\default.master )
and add an scriptmanager :
(asp:scriptmanager runat="server" enablepartialrendering="true" id="ScriptManager1")

just afer

(webpartpages:spwebpartmanager id="m" runat="Server")


Use this abstract class to inherit your webpart from and make it ajax-enabled.

maandag 9 maart 2009

Working with performance counters.

this example reads out two cache performance counters.



next example creates 2 new performance counters and increments their value.

vrijdag 6 maart 2009

Simple delay calculator

maandag 2 maart 2009

New C# 4.0 features

1) dynamic

"most anything that you could do with some variable, you can do with a dynamic variable."

static double SumDouble(double a, double b) { return a + b; }
static decimal SumDecimal(decimal a, decimal b) {return a + b;}

this can now be writen as :

static dynamic Sum1(dynamic a, dynamic b) { return a + b; }

or more generic :

static dynamic Sum2(T1 a, T2 b) {
dynamic
ad = a;
dynamic
bd = b;
return
ad + bd;
}


more:
Dynamically Typed Objects with C# 4.0 (xml example)



2) Named arguments, optional arguments, and default values

By giving method parameters default values.

public class ContactList
{
List<Contact> SearchForContacts(
string name = "any",
int age = -1,
string address = "any") { ... }

static void Main()
{
ContactList list = new ContactList();
var x = list.SearchForContacts(age:26);
}
}
U can then call the method like this:

list.SearchForContacts(age:26);

or

list.SearchForContacts(address:"home", name:"sam", age:30);