Skip to main content

Settings in C# and other lessons learned while converting from VB.Net

 I started converting some of my VB.Net code to C# and have learned a few things. Reading settings was my first stumbling block as there was a lot of incorrect information on the internet. I did finally get it to work and will summarize here.

I have a small application that loads engineering data into a SQL database. The files are basic text files with either XML or comma separated values. I store a few variables, such as path, file type, etc, in the app.config file. In VB it is simple to pull this info:

Path = My.Settings.Folder

In C#, the code is a little different. Here is my final working code for the above example:

 Path = [NameSpace].[AppName].Properties.Settings.Default.Folder;

For me, using the This keyword did not work.

I have also been using this website to convert each Method from VB to C# and have found it very helpful:

http://converter.telerik.com/

A couple of other items that tripped me up are all arrays need brackets, instead of parentheses. Also when you add Trim or ToString to a variable, in C# it needs parentheses at the end. Not a huge deal, but took me a minute to figure out.

Let me know if you have any other tricks or lessons learned to share.

Cheers,
Wade

Comments

Popular posts from this blog

My Art is Showing at the Renaissance Center!

Everyone, I have three images showing this month at the Renaissance Center in Wake Forest NC, below is a link. The show runs from March 7 to April 2. You can purchase my prints online at: https://wade-brooks.pixels.com/collections/recent Gallery Info here: https://www.wakeforestrencen.org/event/march-art-exhibit-reception-wake-forest-camera-club Cheers, Wade

What Next?

 It's time. It's time to do something completely different. Starting in November, I will be retired from Cree/Wolfspeed where I have worked for over 27 years. I feel it is time to move on. With that said, I'd like to do something. Something other than software or database development. I'm not really sure what form it will take, but I am open to suggestions. I know that I don't want to sit at a desk all day. I'd like to do something that helps others or the environment. It doesn't have to be related to photography, but could be. If you have any ideas, let me know. Cheers, Wade

Doing what you love and my 27 years at Cree/Wolfspeed

Working at the same company for 27 years is seen by some as bad for your career. Sure, I may have been able to make a little more money, but I do feel like I have mastered many of the skills I learned while working for Wolfspeed. And I don't think you truly understand a role until you have been submersed in it for a few years. When I started my career there were around 150 people working at Wolfspeed (then Cree Research). I started as a programmer, working on a shrink wrapped software application that controlled LED message signs. In my role, I worked on other software projects and was even involved in building an eight foot full color LED video screen. Very cool! Over the next twenty odd years, I have held many different roles and created some amazing things at Wolfspeed. I created the company's first public web page and also their first internal web portal. At last count, I have created over thirty five applications that are used for data parsing and analysis (and other needs...