Monday, 3 May 2010
Moving this blog
This blog has now moved to codeface.tebco.com
A list of technologies I think I need to learn
However I also want to become proficient in areas I have not spent a lot of time working namely .NET Web Development. To this end I have decided I need to learn the following as part of a couple of private projects I am undertaking.
- Visal Studio 2010
- C# 4
- .NET 4.0
- ASP.NET MVC 2.0
- Enterprise Library 5.0
- LINQ
- Entity Framework
- NUnit
- Moq
Wednesday, 28 April 2010
Learning something new every day
I learned something new today, I learned that stealing someone elses idea is far less satisfying than I had hoped.
What Mark Learned Today
Wednesday, 1 July 2009
Boxing and Unboxing Variables
When using variables in C# you need to be aware of and careful with boxing and unboxing. For example the following code;
int discount = 20;
object discPerc = discount;
discount = 15;
intdiscPercent = (int)discPerc;
In this instance the value of discount is 15 but the value of the implicitly converted discPerc and the explicitly cast discPercent are still 20.
This is because when converting from a value type to a reference type a copy of the value is taken not a reference to the value.
Given that the move from the Value type to the Reference type was implicit you could wind up with an ugly little bug.
Tuesday, 9 June 2009
Generic Classes
public abstract class genericListClass<t>
{
protected virtual add(T value)
{
...
}
}
You can then instantiate a GenericListClass for different type as follows;
genericListClass<int> integerList = new genericListClass<int>()
genericListClass<long> LongList = new genericListClass<long>()
genericListClass<string> stringList = new genericListClass<string>()
You can also accept different generic types as parameters to methods in a generic class
public abstract class genericClass<t>
{
protected virtual CheckBoxOption[] WrapCheckBoxOptions<u>(string id, IEnumerable<checkboxoption> options)
{
...
}
}
The use of the <u> is to ensure it is taken as different from the type reperesented by <t>. <u> is a new different type.
In addition to this you can constrain the type of the class to a specific interface or behaviour;
public abstract class genericListClass<t>
{
protected virtual CheckBoxOption[] WrapCheckBoxOptions<u>(string id, IEnumerable<checkboxoption> options) where U : new()
{
}
}
This allows you to constrain the type <U> to a specific type or more usefully, Interface. You can also use it, as in this case,
where U : new()
to constrain the type to one that can be instantiated with a default constructor. In other words it does not require parameters to be passed to the constructor. So
U newInstance = new U();
will not raise an error.
Monday, 4 May 2009
Extension Methods
public static string ToTitleCase(this string value)
{
...
}
allows you to do the following;
string state = "south west australia";
Console.WriteLine(state.ToTitleCase());
You can extend even interfaces so if you create;
public static IEnumerable
{
...
}
You will find the WhereEven method is available on List
Monday, 27 April 2009
Java now...
I'll still tag this as Learn but will try to use appropriate tags for the subject (Java, etc.)