Well I recently took the plunge and thought I would swallow my pride and learn C# (I told myself at Christmas I'd stay true to ASP.NET VB!), and think about changing to it properly.
As I am fairly new to ASP.NET as well, I thought this was going to be a total nightmare... So I thought balls out, lets just make an application! I opted for a Link Directory, as I know there is a popular PHP one called phpld but there isn't really a true ASP.NET Link directory. The ones that are out there currently are a bit of a mess from a coding point of view.. What I mean is they are more ASP than .NET, they use inc files and don't use any code behinds or classes etc... So I thought this would be a good chance to learn C# and create a well built Link Directory that hopefully people will use.
Well after a week with a few headaches, I managed to get the beta version up
http://directory.n3o.co.uk
I can't believe I am saying this but... I am actually starting to prefer C# to VB!! Here are a few reasons
- It seems quicker to code in
- Creating public properties can be done with one line of code
- There are so many cool ASP.NET C# app's for free
- A lot more people on then net are adopting and blogging about it
- It makes you code a lot better, you HAVE to cast data types and doesn't let you be lazy like VB
Now although I really like it, I have one gripe.. C# is a powerful language but what the heck is with leaving some of the really basic string functions out!! Mid, IsNumeric etc..
So after messing around, and searching the net I collated these functions to help anyone moving from VB to C#.. They make it a lot easier!
public string StringReverse(string str)
{
int len = str.Length;
char[] arr = new char[len];
for (int i = 0; i < len; i++)
{
arr[i] = str[len - 1 - i];
}
return new string(arr);
}
public int InStr(string TheString, string ToFind)
{
return (int)TheString.IndexOf(ToFind);
}
public static string Left(string param, int length)
{
//we start at 0 since we want to get the characters starting from the
//left and with the specified lenght and assign it to a variable
string result = param.Substring(0, length);
//return the result of the operation
return result;
}
public static string Right(string param, int length)
{
//start at the index based on the lenght of the sting minus
//the specified lenght and assign it a variable
string result = param.Substring(param.Length - length, length);
//return the result of the operation
return result;
}
public static string Mid(string param, int startIndex, int length)
{
//start at the specified index in the string ang get N number of
//characters depending on the lenght and assign it to a variable
string result = param.Substring(startIndex, length);
//return the result of the operation
return result;
}
public static string Mid(string param, int startIndex)
{
//start at the specified index and return all characters after it
//and assign it to a variable
string result = param.Substring(startIndex);
//return the result of the operation
return result;
}
public static bool IsNumeric(object Expression)
{
bool isNum;
double retNum;
isNum = Double.TryParse(Convert.ToString(Expression), System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo, out retNum);
return isNum;
}
Anyway.. I am going to be taking my link directory (Now named ASPLD) out of Beta in the next couple of weeks and maybe offering it for free - I am just working on a cool way to let people add themes (And build a few while I'm at it) so it gives people a reason to want to use it.
Here's the link on my site showing some of the features
http://www.n3o.co.uk/software/aspld.aspx