Welcome to Geekdojo Sign in | Join | Help

C# (RSS)

C#

creating string list - why Python is healthier than C#

I needed a string array, so I go string[] tags = new string[] {"python", "ruby", "good"};   but I also need to search for a particular string.. to get IndexOf(...) functionality, I change it to [C# v2] List<string> tags = new List<string>(new
posted by richardhsu | 1 Comments
Filed Under: ,

Running ASP.NET v1.1 on Windows XP Home

At work, i was given a laptop with Windows XP Home as I am travelling for a few weeks. It had a lot of crap software installed and was very slow, so I [in typical geek fashion] I formatted it and reinstalled a fresh version Windows XP Home. There was
posted by richardhsu | 3 Comments
Filed Under: ,

Security - Best Encryption Mechanism in .NET

Somebody from the .NET user group I belong to posted the following, I think keeping data in binary is a really difficult thing in .NET/managed code environment and there is a lot to learn in this. Can someone suggest something.   “Hi
posted by richardhsu | 1 Comments
Filed Under:

String.Split(string) ??

In .NET 1.1, String.Split(..) only accepts char datatype as a delimiter/separator. What if I want to split based on a string ? like “ as “ (read as as with a single space before and after). I couldn't find any quick solution so I came up with
posted by richardhsu | 4 Comments
Filed Under:

Property or Method ??

I needed a way to pass in a list of ids (that should be selected) to a control and also a way to retrieve the selected values only, so here is what I came up with Approach 1 public void SetSelectedAuthors(int[] authorsToBeSelected) {} public int[]
posted by richardhsu | 1 Comments
Filed Under: ,

My little Reverse Iterator in C#

Sometime back, I needed to reverse iterate over a collection and realised that .NET framework didn't provide any 'Reverse' IEnumerable for collections, I remember Standard C++ Library having reverse iterators for the containers. I finally managed to sit
posted by richardhsu | 3 Comments
Filed Under:

using Aliased.Namespace = Namespace.Dont.Want.To.Use.Or.Cant.Use;

I had read the using directive usage for aliasing namespace in Eric Gunnerson's book when I started learning the C# syntax. Yesterday, I had to use it to avoid class name collision (I had two classes named Helper in two different namespaces and I needed
posted by richardhsu | (Comments Off)
Filed Under:

Don'ts in API design (FxCop shows me some Don'ts)

NOT COOL :-1) Properties Should Not Return ArraysWhy ??.NET Framework SDK Documentation :-You should use collections to avoid code inefficiencies. In the following code example, each call to the myObj property creates a copy of the array. As a result,
posted by richardhsu | (Comments Off)
Filed Under:

Working with COM Exe in C#

Credit goes to Peter A. Bromberg for this one. In his article, he talks about creating dynamic excel workbooks in C# within an ASP.NET page. What I learnt from the article was how we can properly release a COM object. There are two methods that we are
posted by richardhsu | 4 Comments
Filed Under: ,

as and is

I read the following from Brad Adams' blog sometime back, I didn't need it then but kind of kept it in mind. Today I needed this one and I actually used it :-). So, hopefully I'll remember it from now on. Yet another 'key of C#' lesson for me. “is should
posted by richardhsu | (Comments Off)
Filed Under:

ArrayList.ToArray(Type) usage

I was using ArrayList.CopyTo(Array) to convert arraylist to a type[] array. I thought ArrayList.ToArray(Type) was for intrinsic types (int, string etc.) but forgot that one the facilitites of OOP is that types that we define can be treated as instinsic
posted by richardhsu | 26 Comments
Filed Under: