Friday, December 29, 2006

strReverse in C#

Just came across this small piece of code while I was looking out to reverse a string in C# and soon discovered there was nothing like strReverse (in VB) in C#.

So obviously needed to look for an alternate. Got quite a few of them but this one looked quite nifty and sleek. Take a look
private string StringReverse(string ToReverse)


Array arr = ToReverse.ToCharArray();

Array.Reverse( arr );// reverse the string

char[] c = (char[])arr;

byte[] b = System.Text.Encoding.Default.GetBytes(c);

return System.Text.Encoding.Default.GetString(b);


-- Ashutosh

Wednesday, December 6, 2006

My Links


Posting after a long time. Got a bit busy with my new house. The construction has started and am really looking forward to it.

BTW. This post wasn't meant for this, but I came across quite a few interesting topics
within these days and decided to post them as a seperate post so that it could be expanded more and more to encorporate new links as and when they are found. Here are a few to start off:---------

1. Introduction to Object Oriented Programming - I

Introduction to Object Oriented Programming - II

Introduction to Object Oriented Programming - III

Introduction to Object Oriented Programming - IV

Introduction to Object Oriented Programming - V

Introduction to Object Oriented Programming - VI

7. Overview of Garbage Collection and IDisposable

8. Convert VB.NET Code to C# and Vice Versa

9. Best Practices For .NET Performance

10. Unions in C#

I would like people to post comments here regarding the links and would be thankful to people if they feel they could contribute to the same and provide me the links for such interesting articles.

-- Ashutosh

Tuesday, December 5, 2006

A new beginning

Hi All,

Today I had a new beginning in my life when I stepped out of Avinex Software Pvt. Ltd. and stepped into eXtensible IT Solutions. Yes I switched my Job.

Well not so obviously, the key factor behind this change was not monetory. Yes believe me.....
I always wanted to grow. Grow in terms of technology, in terms of responsibility and also financially.

At Avinex, I had a few concerns of mine. Ever since I started programming in VB6.0, I wanted to take a dip into the world of C++ programming as well and with the advent of .NET, C# became my new affair.

Suddenly got the opportunity of being a part of a team which was bewing created for development of a product which was supposed to be working as a Middle Tier for a multi ties application AND THAT TOO IN C#. I saw this opportunity as a big one in terms of gaining a good knowledge of OO concepts as well as C#. So grabbed it with both hands.

Secondly at Avinex, I was suddenly finding myself looking straight into a glass ceiling where I could see opportunities of growth but which really were not there. This was getting on me.

And last but not the least, a raise of almost 10 grands a month is never like refusing.

Anyways thats an old story now.

The latest is that I am into eXtensible and am looking forward to a great time over there.


Wednesday, November 22, 2006

A new experience

Today while flirting with ListBoxes and comboboxes, I figured out a strange fact (possibly a bug) with the ListBoxes (infact all List Controls).

Whenever you try to add any attribute to any listitem at runtime using
ListItem.Attributes.Add("onclick","alert('I m a listitem')")
It does add the attribute to the listitem but never really renders the same.

Eg - In case you add an attribute to the listitem above, when you check the page source, you will see something like this:
< option onclick="alert('i m a listitem')" > ListItem </option >
So the attribute has been added but when you click on this listitem, the alert will never come up.

Why Attributes Cannot Be Applied to ListItems of a List Control
Unfortunately none of the list controls render their items' attributes. This is clearly a known bug, as there are plenty of discussions on this topic on the newsgroups. If you use Reflector to poke around the source code of the list controls you'll find that they simply omit any sort of writing of the Attributes. Part of this is probably due to the fact that the ListItem class, which is the class that represents each instance of a list control prior to being rendered. The Attributes
collection is defined in the System.Web.UI.WebControls.WebControl class and automatically is persisted to view state, so that it's values persist across postbacks. Part of the problem lies in that the ListItem class does not derive from WebControl. Furthermore, while it does have an Attributes property, the values are NOT persisted to view state.

More On This And a possible Solution to this BUG on 4GuysFromRolla

BTW : - I am almost done with my CodeConvertor utility and will post the same as soon as it is complete.

-- Ashutosh
PS- Hah it took me quite some time to put the line

< option onclick="alert('i m a listitem')" > ListItem </option >
the way it looks now as the site blocks all HTML tags....;-)

Monday, November 13, 2006

Web Config Editor

Okay, so finally I finished with my web.config editor application. Removed a few shortcomings from it like. Now you have a flexibility of importing / exporting the encryption key within the application and also you can create a new key to encrypt.

Every time a new key is created, the older one gets replaced in the web.config as well.

Still looking for some host. Will try it at geocities.

The whole source code is in VB.NET and is available for download at geocities following THIS link.

You can download and play with it the way you want. And please let me know if you get to improve on the same.

-- Ashutosh

Tuesday, October 31, 2006

Finally !!!!!!!!!!!!!!!!!

Finallly !!!!!!!!!!

Yessss, After a week's head bashing I am ready with my Web.Config editor. Since long, I had been looking for a UI to edit web.config keys in my Application.

As we all know that the key values in development environment are rarely same as in staging and production env. So I needed a UI to edit the config keys and save the web.config file with these new values.

Found quite a few tools for the same but they all were not that flexible. They lacked a few things like Encryption of file while saving and before that, decrypting the same if it is encrypted. So I landed on the conclusion that I would make one of my own.

And yes, after a week's efforts, I finished with a working product for now. It has quite a few shortcomings but surely it serves my purpose and hopefully of a lot others. But there are quite a few catches.

1. It works with .NET Framework 2.0 only as the Encryption-Decryption libraries used are a part of 2.0 only.

2. Currently I am handling only 2 sections of the config file : appSettings and connectionString

3. You need the key file imported in your system if reading an Encrypted web.config file.

Would be looking to eliminate these shortcomings pretty soon.

Oh and BTW I am also looking for a good place to upload this app. so that it could be available to others as well.

- Ashutosh

Friday, October 27, 2006

My Blog

I would like this blog to be rather a collection of my code snippets that I found handy and useful from time to time, so that they could be useful for others as well.

Now since I have been working on .NET since last couple of yrs. This obviously would mean a lot of them will have to be from the same background but from time to time I would try to add code snippets from other technologies as well.

I would absolutely love if someone wants to contribute to the blog. Drop in a mail to me if you wish so.

-- Ashutosh

Friday, October 20, 2006

Yeess I am into it as well....

Better late than never. Even after being so tech savvy (yes I consider myself one ;-) I always stayed away from this blogging thing. Somehow could not understand the funda .....

But now I hope I can sum up my daily ideas into a digest and put them up here. Let see till when it continues. Hope it lasts long unlike earlier....

Not quite impressive like the other blogs I have seen but hope I would pick up with time....

Tuesday, October 17, 2006


The posts here would definitely not be the ones people would be alien about but these are mere a compilation of the topics that I learnt in my day to day working and have found useful conceptually.

I would welcome anyone who would like to share his/her thoughts and findings here to make it a complete Knowledge Base.

If you find the contents here a touch useful, please keep the chain going by linking to this blog so that others get a benefit as well.

Text Link

Ashutosh Vyas's Blog

Button Link

Thanks & Regards

--Ashutosh Vyas