Skip to main content

Posts

Showing posts from April, 2015

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...