CSharpFeeds - All your C# feeds in one place.

Friday, September 03, 2010

Sponsor

Parameters: oh, I don’t know how many I need…

by luisabreu via LA.NET [EN] on 9/3/2010 10:37:34 AM

If you’re a long time programmer/developer, then you probably expect to be able to create a parameter that receives a variable number of parameters.In C#, to declare a method that accepts a variable number of parameters you need to qualify the parameter with the params keyword. Here’s a quick example: static void PrintNames( params String[] names){ foreach (var name in names) { Console.WriteLine(name); } } As you can see, you use an array to represent a variable number of param ...

[ read more ]

Reimplementing LINQ to Objects: Part 1 - Introduction

by skeet via Jon Skeet: Coding Blog on 9/3/2010 6:37:06 AM

About a year and a half ago, I gave a talk at a DDD day in Reading, attempting to reimplement as much of LINQ to Objects as possible in an hour. Based on the feedback from the session, I went far too fast... and I was still a long way from finishing. However, I still think it's an interesting exercise, so I thought I'd do it again in a more leisurely way, blogging as I go. Everything will be under the "Reimplementing LINQ to Objects" tag, so that's the best way to get all t ...

[ read more ]

Thursday, September 02, 2010

Parameters by reference

by luisabreu via LA.NET [EN] on 9/2/2010 9:28:49 AM

By default, parameters are always pass by value. However, the CLR does allow you to pass parameters by reference. In C#, you can use the out or ref keywords for passing parameters by reference. When the compiler sees that you’ve used these keywords, it will emit code that passes the *address* of the parameter rather than its value. Interestingly, these two keywords are identical from the CLR’s point of view. The story is completely different for the C# compiler since it uses them to see who is ...

[ read more ]

Don't let this get away

by skeet via Jon Skeet: Coding Blog on 9/2/2010 6:55:55 AM

Josh Twist asked me this via Twitter: is it possible to invoke a member before a ctor is finished (eg maybe using threaded IL trickery) or is this forbidden somehow? :D Now I don't know why everyone seems to think I enjoy writing code which could have bizarre effects on either you, the compiler, the resulting execution or your co-workers... but it's an interesting topic to look at, anyway. The perils of partially constructed objects Hopefully it's reasonably obvious why it ...

[ read more ]

Wednesday, September 01, 2010

Parameters: by value or by reference? Say what?

by luisabreu via LA.NET [EN] on 9/1/2010 7:33:31 PM

I’m guessing that I won’t be giving any news when I say that parameters are used for passing values into methods. By default, parameters are passed by value. Here’s a quick example which will let us discuss this behavior: public class Student { public String Name { get; set; } public Int32 Age { get; set; } } static void ChangeName(Student std) { std.Name = DateTime.Now.ToString() } As I was saying, parameters are passed by value. And that’s true. However, many still are surprised ...

[ read more ]

Applying Interface Segregation to Configuration Files

by ssmith via Steve Smith's Blog on 9/1/2010 12:22:00 AM

In .NET, it’s very easy to set up custom configuration section handlers to handle your application or component’s configuration needs.  As my previous post shows, it’s also very easy to configure these with attributes that enforce required fields and other validation.  However, over time it’s very easy to create fairly large configuration sections that violate the Interface Segregation Principle, which states that classes shouldn’t be forced to depend on things they don’t need. Consid ...

[ read more ]

Tuesday, August 31, 2010

Extension methods: what, how, when

by luisabreu via LA.NET [EN] on 8/31/2010 9:02:45 AM

I’ve already written a little bit about extension methods in the past. However, since I’ve decided to create a new basics series, I think that I probably should go back and write about it again. I guess that the first thing I need to do is define the what. In other words, *what* is an extension method? An extension method is a static method that you can invoke using instance method syntax. Here’s a quick example: namespace StringHelpers { public static class StringExtension { //don ...

[ read more ]

Monday, August 30, 2010

PropertyOf and INotifyPropertyChanged.PropertyChanged without strings

by Fabrice Marguerie via Fabrice's weblog on 8/30/2010 5:19:00 PM

When coding applications using design patterns such as MVP (Model-View-Presenter) or MVVM (Model-View-ViewModel), you'll find yourself using data binding and the INotifyPropertyChanged interface all over the place. This means referencing properties quite a lot. For example, when you want to notify that the value of a property has changed, you can write NotifyPropertyChange("SomeProperty") where NotifyPropertyChange is a method that invokes the INotifyPropertyChanged.PropertyChanged event. The ...

[ read more ]

Tuesday, August 24, 2010

System.Core in VS2010 Projects

by ssmith via Steve Smith's Blog on 8/24/2010 2:11:49 PM

I just ran into an odd issue with a VS2010 project.  In my case it was an MVC 2 application I was upgrading from VS2008.  One of the built-in controllers (ProfileController) was failing to compile because it could not resolve the Linq extension method symbols Single() and Matches().  These are located in the System.Core assembly.  I checked my project references in Solution Explorer, and System.Core was not listed.  So I tried Add Reference, and System.Core was listed as ...

[ read more ]

Monday, August 23, 2010

What is the difference in <%: variable%> and <%= variable%> in ASP.NET MVC?

by Jeffrey Palermo via Jeffrey Palermo (.com) on 8/23/2010 1:21:26 PM

With many folks adopting ASP.NET MVC as well as Visual Studio 2010, there is a fairly confusing change if you are one of those people who doesn’t engage in the alpha and beta phases of new product releases from Microsoft or any other vendor, for that matter. The issue of <%: vs. <%= has had a great deal of discussion around it in the years leading up to the Visual Studio 2010 release.  This new expression syntax, or code nugget, is a new feature of ASP.NET 4.  It applies equally ...

[ read more ]

Subscribe

New Feed

Product Spotlight

Recently Updated Sources

Legal Note

The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.

Advertise with us