C# Crawler
Sagiv Hadaya is crawling in C#...just for fun

Wednesday, October 16, 2002
Registry R/W article changes...

Registry in C# article was slightly changed, general descriptions where improved and a correction about the Flush() method has been added.

Note that there might be a change in Flush() method from .NET FW version 1, and SP2, seems like SP2 deals better with the MSDN saying that Flush is rarely neede...but that is just a general thinking


12:54:19 AM    

Monday, October 14, 2002
New link

The guys who provided us with the free IDE for VB.Net and C#, also has several interesting .Net free libraries (with full source code).

Among the Libraries released is Zip Library, add that to your application and make it able to read/save Zip files.

1:00:09 AM    
Registry R/W in C#

An article about Reading and writing to system registry has been added to articles section.

The article is making use of the easy Class wrapping: Microsoft.Win32.Registry;

12:43:37 AM    
Got Dot Net?

I am Proud to announce that the amazing site: http://www.gotdotnet.com/team/csharp/

has decided to have me as a C# Friendly member.


12:24:42 AM    
.NET SP2 thingy

I saw this Q once more: My C# project (console) takes over 30 sec. to run, since i double click it...

Well, if you haven't installed .NET Framework SP2 then this might be the reason, but there is a known sollution that does the trick as well:

create a user named ASPNET as a local user account, you can even dissable the user, and supply no password.

But still, i dont know of any good reason (except internet connection problems) NOT to install the SP2!

12:20:44 AM    
C# to VB.Net translator..

Yes, there is such a thing, from C# to VB.Net translation.

tool #1: http://www.aspalliance.com/aldotnet/examples/translate.aspx

tool #2: http://www.kamalpatel.net/ConvertCSharp2VB.aspx

they are both not perfect, and each does have several unsupported features, so try them both, and decide which is perfect for you...let me knoe will ya?

12:15:54 AM    

Friday, October 11, 2002
Article Retrieved - Properting and Indexing

The article 'Properting and Indexing' has been succesfully retrieved from backup, and been placed at the articles section (its now at the links on the right)

1:47:19 AM    
One Process Please!

There are cases when we want our application to be activated only once, if a second instance is opened we want to terminate it, but before that we might want to show the first instance.

A great example is hown here at codeproject, it also good to note that this example is very good at showing how to easily interface with Win32 api's.

1:44:27 AM    
Site update

Site has been slightly updated, to provide extra space for text.

The Articles section now includes all articles that have been posted for the last two months, for extra space and greater archiving.

The Weblog itself will start from now to include only updated on articles added, and/or short C# explanations...meaning that all LOOOONG code examples, or explanations will auto-become articles.

i'd love getting feedback.

1:42:14 AM    

Thursday, October 10, 2002
Install Shield killer

You cant catch me update on bugs daily, but a bug that actually have been discussed in Microsoft formal newsgroup caught my attention for repeating itself over and over...

it seems that installing Install Shield 7 on top of Visual Studio .Net kills the windows installer...well not really but looks like it.

what install shield is doing is removing certain registry keys that are important for windows installer.

so if you got a weird error while compiling a setup project in visual studio .NET:

'An error occurred while validating. HR = 0x80040155'.

don't despair, you can download my export of the registry and import it, close visual studio

.NET, restart it,  and everything will be cool...

12:26:28 AM    
Web services hosting (free)

There is a neat site, that helps in hosting ASP.NET web services.

while there are developers who need to make their web services available to the world, for

tests and/or for out side world usage, this site helps...have a peek



12:21:48 AM    
They gone? ...na

I know that two articles have vanished from here due to me moving the radio, but dont despair, i will retrieve them...

12:20:59 AM    

Wednesday, October 09, 2002
Lets talk unsafe!

An article about unsafe coding in C# has been added to the links section (right).

[...] unsafe code in C# means usage of pointers, what the CLR does behind the scenes when we use a managed code is part of it, and by stating that we have an unsafe code, we declare a function/line to be 'able' to reach memory directly[...]


3:19:07 AM    

Just moved C# crawler to a new computer, forget the mismatch...
2:23:33 AM    

Thursday, September 19, 2002

An easy and fast way to create unique ID's for your application is GUIDs,

A GUID is a 128-bit integer (16 bytes) that can be used across all computers and networks wherever a unique identifier is required. Such an identifier has a very low probability of being duplicated.

in C# we create a new guid like so:

System.Guid guid=System.Guid.NewGuid();

this will generate a guid out of your local MAC (network adapter physical address which itself is unique) your local time, and more...if you run this more then once: guid=System.Guid.NewGuid();  you are guaranteed to NEVER get the same guid again.

9:49:14 AM    
Threads made easy

Dont believe everything they told you...Threads in C# is not hard, in fact its not even easy, its SUPER easy.
A thread is an encapsulation of the flow of control in a program. you might be used to
writing single-threaded programs
a new article is now available through the articles section (the left pane) or here

9:36:34 AM    

Tuesday, September 17, 2002
Is my string Interned?

String interning...what does it mean? catch a new article (right) that explains that exact issue.

[...]Defenition: The CLR maintains a table (the "intern pool"), which holds one instance of each unique string declared in a program, as well as any unique instance of string you programmatically added[...]

2:20:54 PM    

Thursday, September 12, 2002
Downloader App

This you will all love...i hope.

I have wrote an application which make use of the easy class in C# - WebClient.

the application logs into a playboy pics site, and downloads ALL pictures from the site to your computer...now notice that its about 600 pics!!!

its on the articles section to the right.

6:00:37 PM    

Tuesday, September 10, 2002
Reading from Console

A very nice,easy and smart way to run a console application as a second process from your console application, and read its output into string buffer of your application.

Articles links to the right.

2:18:35 PM    
Abstract in my Class

Abstract abstract abstract, what is it?

well read it all on the new article about C# Abstract Classes.

1:50:14 PM    

Wednesday, September 04, 2002
Hashtable: add versus property

In my last Hashtable & serialization example, you my have noticed a Hashtable addition that has a different approach then the retrival.

for addition we used: myCollection.add(mn,ad);

for retrival we used: ad = myCollection[mn];

where myCollection is the hashtable, mn and ad are structs.

i got an email saying that an addition could be performed as such: myCollection[mn]=ad;  and that is correct and excellent, but lets point the differences between property addition and add method:

While using a property addition (eg myCollection[mn]=ad;) we can add new items, However, if the specified key already exists in the Hashtable, setting the Item property overwrites the old value. In contrast, the Add method does not modify existing elements, and if the item exists, an exception is thrown.

hope that clears things up.

12:04:11 PM    

Tuesday, September 03, 2002
Hashtable serialized

Just added a new **article** to the articles section (left).

this article shows a full usage of the hashtable data structure in C# and a way to serialize it into a binary file.

the full application is a phone-like book, you can freely change it and use it as you wish.


any questions regarding that article will be hapily answered

2:54:09 PM    
Find & replace insensitive

This has been a question that i saw couple of times at the Microsoft news groups...and it goes something like that: "Is there a way to search a given string for a specific sub-string and replace that with another, but the string to be searched will be case insensitive?"

And i decided to sit down and hit the keyboard until a nice function will come up, and it works,,,check the articles link (right) for the 'Find & replace Insensitive' article...

1:11:45 PM    

Thursday, August 15, 2002
Play with C# strings (my 1st article)

Check out my first article, on the 'articles' link to the left (below the 'home' link).

the article shows how to transit to C# form C++ and not be afraid from the strings...and chars....and ....well read the damn article.


10:37:23 AM    
Convert to HEX

Q: How can i convert an integer to HEX?

A: One way would be:  string str = System.Convert.ToString(integer, 16);


Basically, i feel that System.Convert namespace holds everything i need for any conversion needed..


10:03:04 AM    
Mosquito Prevent !

There is something that we can all agree to hate, the incessant buzzing of a mosquito flying around our heads. it can really drive us nuts.

An amazing new use for the pocket pc has come to the rescue..:the Mosquito killer app, i dont know ho good it is, or maybe bears come instead of mosquito's, but its a damn good idea.

9:43:36 AM    

Wednesday, August 14, 2002
Coming to an Ethernet port near you ...

XBox Goes Live... a dream comes true for many XBox players...ohhh ya.

9:14:27 AM    

Tuesday, August 13, 2002
Good (Great) TCP/IP Tutorial

TCP/IP Tutorial. Ran into a good introduction to TCP/IP, including simple explanations of the various layers and protocols and a detailed explanation of addressing. Recommended reading. [Peter Drayton's Radio Weblog]
7:23:37 PM    
Free C# IDE (plus source)

A great and usefull IDE for C#, its great because its free, it comes with the source, and its written ontop .NET.

myself? well i am a Microsoft Freak, so i use Visual C# (Visual Studio .NET)

6:44:10 PM    
Microsoft in LinuxWorld

Microsoft Puts On the Tux. What's Microsoft doing at LinuxWorld, which starts Tuesday in San Francisco? And what is it doing with such a big booth? 'I can't honestly say that I believe everyone at the show will be happy to see us,' a company official admits. By Michelle Delio. [Wired News]
5:39:32 PM    
Are you allergic to pentiums?

Woman claims she's allergic to Pentiums

...But not to 486s

The woman has filed a lawsuit against the Ministry of Economics in the Netherlands, and, apparently against Intel too, claiming that the processor gives off particular radiations which cause her to break out in hives. [...]

1:09:01 PM    
Fuel Battery..

For PDA's, Cell Phones, and actually everything there is... MTI is a company who works on a new generation energy cells...these energy cells are fuel cells. you can catch the company's technology info here.

Basically they are working now on compacting the cells, and placing them im hand held devices. all researches show that a fuel cell can power a device twice the time that a normal Li-Polymer Battery can.

The funny question is...will we stop at a gas station and ask for cell phone re-fuel?

9:42:33 AM    

Monday, August 12, 2002
A non blocking chat application

This is a very good article, with a depth explanations on how to build (write) a C# chat application.

what is unique, is that this application is non blocking, and teaches the secrets of C#-Sockets.



source [CSharpFriends]

6:35:39 PM    
Triple XOR

Lets implement a string reverse in C#
in most sites you will see an implementation using a recursion:
public static string Reverse(string str) 
	/*termination condition*/
		return str; 
		return Reverse( str.Substring(1) ) + str.Substring(0,1); 
but in C# Crawler, i will show you a nicer version (i think) that uses 
the old trick - triple Xor.

private string Rev(string x)


char[] c = x.ToCharArray (); /*convert to chararray*/

int l = x.Length -1;


for (int j=0;j<l;j++,l--)


c[j]^=c[l]; /*triple xor will */

c[l]^=c[j]; /*replace c[j] with c[i]*/

c[j]^=c[l]; /*without a temp var*/


string s=new string(c); /*convert back to string*/

return s;


6:03:56 PM    
Access Levels in C#

I have been asked about access levels avilable in C#, there are 5 of them, and could be remembered as PPIPP!!!

the top level is Public, which is no restricion.

the second one is protected, which allows access for the containing class, or lass that inherit it.

the third one is internal, which allows access only for the corrent project.

the forth one is protected internal (the only combination available), which allows access for the corrent project, or derived types derived from this class.

the last one is private, and its the most restricted one, allows access only for the containing type.


2:41:47 PM    
IExplore Pop-ups spy

...from CSharpHelp.com

Often when surfing web site, we get frustrated with all the small pop-up windows and advertisements that appear on the desktop. Well I got so frustrated with those, that I thought of writing a small application that can automatically close such windows [...] by Shripad Kulkarni

1:11:41 PM    
Things to avoid while migrating to C# (part 1)

Someone asked me, are there any things that might be confusing in c# if i was a C++ programmer?

I say yes, but i like to call it simplicity.


Simplicity in C# comes to break apart all the annoying things in C/C++. for example, have you ever wrote an if statement in C/C++ that looks like this:

if (x = 0) { . . . }

and wondered for days what went wrong? (if you have'nt noticed, this simple if statement actually assign x with 0, and not comparing it with 0).

In C# you cant do that, C# compiler will complain that this (x=0) statement is not a bool one, and cannot be converted to bool, which means that you must explicitly state every if/while/... as bool, that cannot be converted to other types.

Another thing is Switch statements...a very common place for fall downs;

In C/C++ something like this is ok:

switch(x) {

case 1:

case 2:



case 3:

case 4:





What it means is that case 1 and 2 are "fall through". when x is 1, the switch statement will fall through 2 and up until it hit the break.

in C# every case has a break, this line on code (6 lines if you will) will cause the compiler of c# to generate a break after EVERY case. and if we wanted fall through? well consider this:

switch(x) {

case 1:

         goto case 2;

case 2:



case 3:

        goto case 4;

case 4:





to gain the same effect.


I will be happy to get comments this line of articles.


10:30:32 AM    
Why does C# holds 'Ref' and 'Out' all together?

Have you asked yourself that?

Well i have, and i have the answer for you: Ref and Out are two seperate animals, they both might sound the same, but they eat difrerantly :)

When a function is set to have one or more of its variables as ref, it means that the caller MUST assign a value to that ref variable, and the callee will change it (does not have to). making a long sentance short - ref means that the caller must assign a value (or the compiler will for you) before calling the function.

On the other hand, an Out parameter means that the caller is not required to assign a value to that out variable, but the callee must ,and will, assign a value before returning the variable to the caller.

9:48:42 AM    

Sunday, August 11, 2002
How Al-Qaida Site Was Hijacked

Very Interesting....must read!

How Al-Qaida Site Was Hijacked. Using tracking tools, a public Web service and impeccable timing, an American hacker explains how he managed to take over al-Qaida's dot-com domain. By Patrick Di Justo. [Wired News]

6:01:02 PM    
is it fast .Net?

Check this out: im not really sure, but it seems that the C# compiler (considering pure managed code) is far more fast than the VC++ comppiler..or is it?

please email me if you think i missunderstood it.

5:43:10 PM    
Riddle answer

Well, after waiting for your responses...here is the answer for the riddle:

the riddle was: [...]You have 3 vending machines, each have a lable WHICH IS MISPLACED (3 vending machines that no machine has its correct label). one machine say 'oranges' the other say 'apples' and the third one say 'apples and oranges'. each machine when given a coin, is spilling a product. by defalt, the machine that is ACTUALLY the 'pples and oranges' spill products randomly.

given this story..how many coins do you need in order to set the 3 lables to thier correct places?

the answer is 1...yes 1.

if you write down all posibilities for each machine you will come to this:

apple machine (label is incorrect) - could be oranges or mix.

oranges machine (label is incorrect) - could be apples or mix.

mix machine (label is incorrect) - could be apples or oranges...

now, we have one coin, so we put it in the mix machine, if we get apples, then its an apples machine, if we get an orange then its an oranges machine.

after that, we look at the 2 machines there were left, we can eliminate the machine that we found from one of them, and its left to be a mix...and the third one is... what's left.



5:00:24 PM    
Right On..

far more simplified version, now using the .ToCharArray() method. thanks to Joe Labrock.

using System;

namespace ConsoleApplication3


        class Permute


                 private void swap (ref char a, ref char b)







                  public void setper(char[] list)


                        int x=list.Length-1;



                  private void go (char[] list, int k, int m)


                        int i;

                        if (k == m)


                                 Console.Write (list);

                                 Console.WriteLine (" ");



                             for (i = k; i <= m; i++)


                                   swap (ref list[k],ref list[i]);

                                   go (list, k+1, m);

                                   swap (ref list[k],ref list[i]);




         class Class1


               static void Main()


                      Permute p = new Permute();

                      string c="sagiv";

                       char []c2=c.ToCharArray ();

                       /*calling the permute*/





4:46:48 PM    
1st Solution!

I have managed to write an application that writes down the permutations of a string.

if somebody has a better way to 'swap' two chars in a string... let me know.


using System;

namespace ConsoleApplication3


class Permute


public void swap (ref string str, int pos1, int pos2)


if (pos1 == pos2) return;

if (pos2<pos1) // swap positions, so pos 2 will be the higher






string temp;

temp = str.Substring(0,pos1);

temp += str.Substring ((pos2),1);

if (pos1+1 != pos2)


if (pos1==0) temp += str.Substring ((pos1+1),(pos2-1));

else temp += str.Substring ((pos1+1),(pos2-2));


temp += str.Substring (pos1,1);

temp += str.Substring ((pos2+1));

str =temp;


public void go (string list, int k, int m)


int i;

if (k == m)


for (i = 0; i <= m; i++)

Console.Write (list [i]);

Console.WriteLine (" ");



for (i = k; i <= m; i++)


swap (ref list, k,i);

go (list, k+1, m);

swap (ref list,k,i);




class Class1


static void Main()


Permute p = new Permute();

string c="1234";

p.go(c, 0, 3);




10:57:21 AM    

Thursday, August 08, 2002

yes, another great link, with an exception!

this C# Link has some great lessons, and great tutorials on c#...another worth a peek

6:57:49 PM    
Do you know C#?

Do you know C#?

i have a question...C# of course...

what if i told you i want a simple C# function that will get a string as an input, and print out (console if you will) all the permutations of that string...can you do that?

give me an email...ring ring

6:33:03 PM    

CSharp Friends (of mine)

Just added a cool new link (to the right)...CSharp Friends is worth a look, a very solid place for the beginners and the experts...


6:14:42 PM    


i have been asked a cute riddle.. lets see who email me the answer.

You have 3 vending machines, each have a lable WHICH IS MISPLACED (3 vending machines that no machine has its correct label). one machine say 'oranges' the other say 'apples' and the third one say 'apples and oranges'. each machine when given a coin, is spilling a product. by defalt, the machine that is ACTUALLY the 'pples and oranges' spill products randomly.

given this story..how many coins do you need in order to set the 3 lables to thier correct places?

10:37:38 AM    

.NET Service Pack 2 Just Released!!. Microsoft .NET Framework Service Pack 2 provides the latest updates to the .NET Framework. Service Pack 2 is highly recommended for all users of the .NET Framework, including customers of Visual Studio .NET. [Sam Gentile's Radio Weblog]
9:32:20 AM    

Click here to visit the Radio UserLand website. © Copyright 2002 Sagiv Hadaya.
Last update: 10/16/2002; 12:54:35 AM.
October 2002
Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Sep   Nov


Subscribe to "C# Crawler" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.