Posts

Showing posts from June, 2017

C# 7 and Beyond!

Image
The Future is Now I watched an interesting YouTube yesterday about the Future of Microsoft C#. I have to admit that I've been on a spurt lately (starting this last February) of being interested once again in software development and a lot of my interest is due to C# (the instigator was getting back into Microsoft MVC with C#). I've been writing software to one extent or another since about 1980. Yeah, I'm an old dude - I'll turn 60 this year. I've been developing software as a primary occupation since 1997. 20 years. Before that I had always written software to some level to assist me in my jobs. In the Navy I wrote a small program on my HP-41CV programmable calculator that would solve passive targeting solutions for anti-submarine warfare (TMA if you're familiar with it). Since I was also tasked with being the secret materials officer, I wrote a database tool for tracking the secret materials. And it did not use an off the shelf database - I wrote my own ...

More Info from Microsoft RE: Visual Studio 2017 Upgrade Woes

Microsoft Responds I posted a few weeks ago about my problems that I encountered when upgrading Visual Studio 2017 from version 15.1 to 15.2 (those different ways that you refer to Microsoft applications sure are confusing. I wish they'd just refer to Visual Studio 2017 as Visual Studio 15 and when they have major updates to, say, 15.2, it would not be as cumbersome to discuss). I had posted my issue to the Visual Studio Developer Community  website which seems to be the new Microsoft website for everything Visual Studio (I wonder how long that will last?). I had some response from Microsoft representative Raja, and he pointed me in the direction of how to fix my upgrade woes. But eventually I un-installed every developer tool from Microsoft that I could, ran a bunch of CCleaner  registry cleanups and reboots and eventually got Visual Studio 2017 up and running again. I couldn't see how to close my post at the Visual Studio Developer Community (Microsoft reps have to do...

C# "IsNumeric" Extension Method

IsNumeric Function for a Loooooooong String Value I had a failure on some production code when testing for a Social Security Number. The code was testing string inputs provided by a file upload to ensure that they were positive numeric and exactly 9 digits long (no punctuation was allowed in the input). That seems easy enough but one of the requirements was to try to provide as much error or validation failure information as possible. If the string wasn't exactly 9 digits that failure information should be returned to the user. In addition, if the string value did not evaluate to a numeric value, that failure information should also be returned to the user. The problem was that if the string was not exactly 9 digits, it could be 20 digits. The code had been using an Int32.TryParse which will successfully test a value up to 2147483647. String.IsNumeric() After poking around, I found this solution which I think is pretty cool. I added an IsNumeric() extension method to st...

New to me but solved an issue - Templated Helpers

Image
Building and Modifying Razor Display Helpers  Note: this post uses Microsoft C# only (as most of mine will). I'm using Visual Studio 2017 with C# 7. I have created quite a few Html Helpers and they come in very handy. These are the C# static method kind such as the following which performs some rudimentary formatting of an address: /// <summary> /// Creates HTML for an Address section. /// </summary> /// <param name="htmlHelper" /> /// <param name="address" />The Address object to create the HTML for. /// <param name="refTypes" />An IEnumerable list of reference types  /// (used to parse the name of the address state). /// <returns>Formatted HTML representing the Address object.</returns> public static IHtmlString AddressInfoFor(     this HtmlHelper htmlHelper,     IAddress address,     IEnumerable<IReferencetype> refTypes ) {     var state = UIHelpers.GetStateName( add...

Implementing IDisposable Properly

Image
The Confusion of IDisposable Maybe it's just me but I have a hard time figuring out the best way to implement IDisposable, let alone when to use the interface. I understand the basics, that you use IDisposable to manage releasing managed and unmanaged resources. But why do you need to use it? I have been looking online for information about IDisposable and there is a lot available, both from Microsoft as well as others. I have to say, though, that I spent some time this morning going through what I find to be the best information source I've seen: Pluralsight's  IDisposable Best Practices for C# Developers by Elton Stoneman You do have to have a Pluralsight account in order to watch this course but it was worth it to me. Note: Pluralsight offers a 10 day free trial on their website. You can also get a free 3 month trial to Pluralsight by joining the free Visual Studio Dev Essentials program. The program has a lot of other features as well, such as the GIT...