Protected: My Silverlight book is out!
There is no excerpt because this is a protected post.
Ramblings about C#, .NET and Programming
There is no excerpt because this is a protected post.
After a small JavaScript detour, I’m back into .NET land. We’ve already seen several interesting details regarding methods, but we still haven’t really discussed the concept of overloading. So, what’s method overloading? The concept is simple, but before, we should probably find a good enough definition for a method. For now, lets define a method […]
Even though I’ve been in Silverlight/C#/WCF land in these last months, the truth is that I’ve always been a JavaScript aficionado. In fact, if you’ve been reading my blog, you’ll probably recall a small series I’ve done on it a few months ago(if not, then don’t worry: you can still read it here). After speaking […]
In some languages (ex.: C#), you can customize the way an operator works. For instance, if you take a look at the String type, you’ll notice that it has these peculiar looking methods: public static bool operator !=(string a, string b); public static bool operator ==(string a, string b); What you’re seeing here is known […]
After a few months of using the Paste from Visual Studio plug-in for copying code from VS to Windows Live Writer, I think I’ve found something better for this sort of thing. It’s called Paste as Visual Studio Code and I do like the way it works. The best thing about it is that it’s […]
In the previous posts, I’ve presented the basics on boxing and unboxing. Today, we’ll take a deep dive into several scenarios which illustrate how boxing/unboxing can occur without you even noticing it. Lets start with a quick recap. Suppose we’ve got the same structure as used in the previous examples: public struct Student { public […]
[Update: Thanks to JPC for finding (yet!) another error in my post] Yes…well, it is, but it’s cheaper (as we’ll see). As we’ve seen in the previous post, we can convert a value type instance into a reference type instance through an operation known as boxing. Unboxing lets you convert a reference type into a […]
As we’ve seen, value types have better performance than reference types because they’re allocated in the stack, they’re not garbage collected nor do they get the extra weight generally associated with reference types. There are, however, some times where we need a “reference to a value object” (yes, I wanted to write “reference to a […]
One of things I’ve been doing lately is reading the HTML 5 spec. Before you tell me to sod off, don’t forger that HTML 5 is here…to stay, I’d say! Yes, there’s still no final version and the RC is only planed for 2012, but the thing is that most browsers are implementing the current […]
One of the books I’ve re-read during my August vacations was Don Box’s Essential .NET. Tentatively called Essential .NET, Volume I: the Common Language Runtime (I say tentatively because there never was a volume II), it’s really one of those interesting books which you need to read for understanding and having some background on how […]
[Update: thanks to Wesner, I’ve fixed the list you should consider when using value types] In the previous post, I’ve talked about some basic features related with reference types. If all the types were reference types, then our applications would really hurt in the performance department. In fact, hurt is really a kind way of […]
Most types introduced by the framework are reference types. So, what is a reference type? Take a look at the following code: Student std = new Student(); When you instantiate a reference type you end up with a…yep, that’s right: a reference to the instantiated object. Notice that I said reference, not pointer. People tend […]
After a bad week (where my work machine died), I’ve finished reinstalling everything. This time, I’ve went with Windows 7 and as a bonus, I’ve ended up with IIS 7.5. One of the things I needed to recover my working environment was to configure access to the certificates’ private keys (I have several WCF services […]
In the previous post, I’ve introduced the concept of primitive type and we’ve seen how they’re treated in a special way by the compiler. One interesting topic that pops up when we talk about primitive types is operation overload. For instance, what happens when you try to run the following snippet: var max1 = Int32.MaxValue; […]
If you’re not new to .NET, you’ve probably heard several times that one type can be a value type or a reference type. Well, that is true. What people miss (sometimes) is that they’ve also got some data types which are used so often that compilers allow code to treat them in a simplified way: […]
In the previous post, we’ve seen the difference between type visibility and member accessibility. A type can be visible to all the other types defined in the same assembly (internal) or it can be visible to any type, independently from the assembly where it’s defined. On the other hand, member accessibility controls the exposure of […]
One of the things I’ve noticed while trying to help others get started with the .NET framework is that they tend to confuse type visibility with member accessibility. In this quick post I’ll try to point out the differences between these two concepts. Let’s start with type visibility. When you create a type (ex.: class, […]
In the previous post, I’ve talked about partial methods and I’ve promised that the next post would be about partial classes. And here it is! Now that I think about it, I should have written this post before the one on partial methods, but this order will have to do it now, won’t it? The […]
In previous posts, I’ve mentioned extension methods and how you can use them for extending existing types. After talking with a friend, I’ve noticed that I didn’t mention partial methods, which are really useful for code generators. Imagine you’re writing the code generator that needs to generate C# for some specs which are defined through […]
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[] […]
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 […]
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; […]