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:
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:
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.
Comments
Post a Comment