• Code
  • Tags
  • Users
  • Titles
  • Log in
  • Feedback
  • FAQ
Share Code
Welcome to ForkCan.com

ForkCan is all about sharing code in a social way.

Discuss, debate or argue with other devs about their or your own code.

Give other devs feedback or make a Fork (Make a better version of a shared code).

Rate the code, if you use the code mark it as used so others can see if the shared code is used by someone.

Help each other to be better devs and to be more productive.


Features not working yet:

Flag a post


QR Code

Tiny Url

http://4kcan.com/s/NjA2

Related Code
Serialize an object into a Querystring
Using DynamicObject to get a value from the Request.Params
Simple LINQ implementation for .NET20
Fork of GZIP your Actions in MVC if not used as standard in IIS7 or only use IIS6
A simple way to cache slow functions in C#
ActionFilter to Handle and Log Error for each Controller, ASP.NET MVC
Serialize (anonymous) objects to xml
Get Cookies in Web Api Asp .net Mvc 4 RC
GZIP your Actions in MVC if not used as standard in IIS7 or only use IIS6

Fork of Serialize an object into a Querystring, using LINQ syntax

Can be used to serialize an object to a QueryString.

1
1.07k 0 1 0 0 0

public static class HtmlHelper
{
    public static string SerializeToQueryString(object source)
    {
        if (source == null)
            throw new ArgumentNullException("source");

        return String.Join(
            "&",
            source.GetType().GetProperties()
                .Select(p => new { Name = p.Name, Value = p.GetValue(source, new object[] {}) })
                .Where(p => p.Value != null)
                .Select(p => String.Format("{0}={1}", p.Name, p.Value))
                .ToArray()
        );
    }
}

Share: twitter | facebook   Action: used | fork | flag

asp.net

Mark 'asp.net' tag as 'like'

Mark 'asp.net' tag as 'ignore'

c#

Mark 'c#' tag as 'like'

Mark 'c#' tag as 'ignore'

html

Mark 'html' tag as 'like'

Mark 'html' tag as 'ignore'

linq

Mark 'linq' tag as 'like'

Mark 'linq' tag as 'ignore'

serialize

Mark 'serialize' tag as 'like'

Mark 'serialize' tag as 'ignore'


 @benlaan
105
February 17, 2011 6:03 AM

Fork

 Serialize an object into a Querystring -  @fredrikn Wednesday 16, 2011 3:07 PM
 Fork of Serialize an object into a Querystring, using LINQ syntax -  @benlaan Thursday 17, 2011 6:03 AM


1 Feedback

Great! But we need to urlencode the name and value. -  @toha73 Tuesday 22, 2011 11:10 AM

You must log in before you can give any feedback


0 Discussion(s)

Newest Oldest

You must log in before you can post a comment

Squeed
Made by: Fredrik Normén 2010