Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Thursday, January 19, 2012

What is a Method Group?

A method group is the name for a set of methods (that might be just one).
The ToString function has many overloads - the method group would be the group consisting of all the different overloads for that function.
It is a compiler term for "I know what the method name is, but I don't know the signature"; it has no existence at runtime, where it is converted in the correct overload.
Also, if you are using LINQ, you can apparently do something like myList.Select(methodGroup).
so you can replace this code:
private static int[] ParseInt(string s)
{
    var t = ParseString(s);
    var i = t.Select(x => int.Parse(x));
    return i.ToArray();
}
with this one:
private static int[] ParseInt(string s)
{
    var t = ParseString(s);
    var i = t.Select(int.Parse);
    return i.ToArray();
}

Submit this story to DotNetKicks

Saturday, January 14, 2012

SlashDot Blogger integration that actually works!

You can add a badge or link to your Blogger to easily allow your readers to submit it to Slashdot for consideration; and once submitted, take them to the discussion.

Full description on how SlashDot badges work is here: http://slashdot.org/faq/badges.shtml

This is the actual code that you need in your template:

<script type="text/javascript">
slashdot_title="data:post.title";
slashdot_url="data:post.url";
</script>
<script src="http://slashdot.org/slashdot-it.js" type="text/javascript"></script>

To add the tag into your post template go to the Template tab under your Blogger accounts Customization section. Select "Edit HTML" and check the "Expand Widget Templates" check box. Scan the template until you find a line that looks something like "<p><data:post.body/></p>". That is where the Blogger templating engine inserts the body of your post.
I inserted my tag to appear directly below the body of my posts but you can play around with whatever position you like by using the "Preview" button. You’ll have to save the template to apply the changes when you are satisfied.

I tested the corrected code, and it’s working great!
The only probrem here is that title seems to be ignored, no idea why.
Source is correct, for some reason it is not passed to submit url page on SlashDot.

Submit this story to DotNetKicks