Articles and tutorials on .NET Core, ASP.NET MVC, Kendo UI, Windows 10, Windows Mobile, Orchard
This function is one of the useful addtion to the language in C# 6.0 and will see a widespread adoption. We as developers have written many times the below code numerous times in our life.
In this basically we are checking whether the parameters are properly set according the business rules and if it's not then throws the ArgumentNull exception with the message saying that this particular property is not set.
Suppose after some time we decided to change the name of the properties, went ahead with using the refactoring options available in Visual Studio. In the example I removed the term Product from all the properties using the refactoring option, but the messages for the ArgumentNull exception won't change since it's inside string literals.
Now when the exception occurs there is a mismatch between the actual property name and the name in the message. Imagine if this occurs in a class containing a lot of properties then it take some time to make the corrections and also there's a possiblity of missing out on some.
C# 6.0 brings the ability to initialize an auto-properties pretty much like the way we do for a field. This helps you to intialize the backing field without woking through the setter of the auto property or making using of a local variable. It's executed in the order as written and not at the time when the object is initialized. It means that we cannot reference it using this keyword since the property iniitialization happens before the object intialization.
In the earlier versions, suppose if we want to initialize the properties to some default values we were doing that at the time of instantiating an object as shown below
In C# 6.0, now it's possible to initialize the values for the properties at the time of declaration itself.
Many of you may be wondering why I am using a $ symbol in front of the string and how can I use the C# syntax inside the string which is later transformed into the correct message during execution of the code. It's the new String interpolation feature in C# 6.0 and you read more about it here.
And you can mix and match the defaults with the ones you want as shown below. In this example, I have modified the default values at the time of instantiation for FirstName and LastName properties and left the Email property untouched
Also we can initialize it without a setter also.
Dictionary initialization was first introduced with C# 3.0 and the syntax for the same remained same since then.
In C# 6.0 the syntax was tweaked little bit to make it more friendly to maintain. As we all know in a dictionary object, information is stored as key value pairs and if you look at the above syntax a lot of curly brackets and punctuation marks are used. This makes it pretty ugly and doesn’t reflect the data structure which is holding the data.
The new syntax reduces the number of keystrokes and the code is now more elegant and readable by omitting some curly braces and the syntax now uses the equals sign which helps you to recognize the info in a key value pair format
Even though they have introduced a new way on initializing dictionary objects, the old way of writing is still valid and it’s up to you developers to use which one.
Up untill now we are using various options for formatting strings using String.Format or by concatenating string values using + operator or String.Concat function.
In the case of using + operator , as the number of items that needs to concatenated increases it becomes very hard to maintain and to understand what we are doing and some times it may result in incorrect string ouput too.
This can be solved to some extent by using the String.Format function by using the literals as placeholders so that we will get to know what the output be in advance by looking at the text part. But here we may find problems if we don't give the parameter values in the same order as in the string text part. Also if the number of placeholders and the values in the parameter list are not in sync an exception will be thrown at runtime.
In C# 6.0, Microsoft added a new feature to make our life easier by allowing us to put the expressions directly in the string literal. Now we can inject the values into a string using curly bracket enclosed expressions.
Every developer who writes C# code should have encountered NullReference exception or Object Reference not set to an instance of an object error at least once. This error normally happens when you try to invoke a member of an object without performing a null check on the object. For example the following code will produce a compiler error
So normally to solve this issue we will introduce a conditional checking before invoking the property as shown below
SignalR is a library from Microsoft which can be used for enabling real-time functionality in your web applications. SignalR uses web sockets feature in HTML5 to maintain a persistent connection between the server and the client. Because of the stateless nature of the web, it was very hard to maintain a persistent connection in the pre HTML5 era and we used techniques such as long polling, meta refresh tag or some timer logic coupled with AJAX calls to achieve it. Please visit their site or in GitHub to read more on the features and documentation, also the entire code is available there.
SignalR API contains two methods for communication between client and server
1. Persistent Connections - Represent a single endpoint for sending single-recipient, grouped or broadcast messages. It’s similar to communication based API’s such as WCF.
2. Hubs - Built upon the Connection API that allows the client and server to call methods on each other directly.Similar to other remote invocation API’s such as .NET Remoting
Picture Courtesy : SignalR Documentation
With the clock now past the midnight to ring in July 29th, Microsoft went live with the release of Windows 10 worldwide in 190 countries and in 111 languages. The upgradation will start in each country by 12.00 AM and the rollout process will happen in batches and in a staged manner, so those who reserved their copies don't get worried about the upgrade for the time being, it will be coming to your machines very soon. Also the links for ISO files are also now live, but the catch here is that you will need the serial number during the installation process, for those who have that right now they can proceed with the installation using the iso files. The instructions and links for the iso files can be found here.
Currently there is a workaround for those who have reserved the copy for Windows 10 and yet to see the update, please find this post in the Windows Central site. I haven't tried this one yet, so proceed with this at your own risk if have ran out of patience. In the meantime you go through these links which has in depth reviews, tip and tricks, help guides etc
- Windows 10 FAQ
- Windows 10 Official Blog
- Windows 10 review by Windows Central
- Review by Neowin.net
- Windows 10 Quick Guide
- Windows 10 Help, Tips & Tricks
- Articles by Tech Repository on Windows 10
- Nine Important Things in Windows 10 by The Verge
Watch this space for more on my upgradation experience and till then have fun with the ninja cat
This one statement was the biggest surprise from Microsoft since they announced their plans to release the next version of Windows to the masses. Yes, you heard it right, they are giving it free for all for a year from the date of the launch and anyone wishes to install after that will need to shell out some money. They will be providing support and unlimited access to updates also for those who jumped in the first year too.
The dwindling sales of the desktops and laptops as well as the poor response to previous version may have forced Microsoft to take this step. But as more and more services and enterprises embracing the cloud and the future plans for Windows as a Service will help Microsoft to gain the lost ground in the long term.
So do I need to really really upgrade even if the offer is tempting ?
Windows XP, Vista
If you are running on Windows XP, then you should really upgrade it. We all know it was one of the best product to come out of Microsoft, but it has reached the end of the life cycle long back and also it was developed prior to Web 2.0 and there are many shortcomings in the OS to run in the modern web era.
If you are running on Windows 7, then it will be a difficult option to switch. If you are okay with the OS, then there is no need to upgrade right now. Windows 10 still has some feature from Windows 8.0/8.1 and if you are not going to use any one of them, then stick with the current one. But if you want to exploit the under the hood features of Windows 8 such as faster boot up time, improved task manager, one drive syncing and additional features such as Cortana, Virtual Desktops , then go for it. You won't find much difference between the two softwares and will get you going from the day one itself.
Should upgrade. Windows 10 removes most of the annoying things in Windows 8/8.1 and it's now much more user friendly for non-touch input when compared to the previous version.
Also the free upgrade can be done only for the ones having a valid license of Windows XP/7/8. If you are running a pirated version then Microsoft will allow you to upgrade to Windows 10, but still it will be an unlicensed one.
As we all know that Window 10 is slated for release on July 29 in 190 countries and 111 languages. The new incarnation of Windows is designed to run on a variety of devices such as Surface Hub, Desktop. Laptop, Tablets, Phone, XBOX, Holo Lens and also on IoT devices. To cater these devices Windows 10 comes in various flavours and let's take a look on each one of them.
Windows 10 Home
Targeted for home consumers, runs on desktops, laptops, tablets and 2-in-1s. Will have Cortana, Edge, Continuum support, Windows Hello, universal apps such as Photos, Mail, Calendar, Music and Video.
Windows 10 Mobile
Designed for smaller devices such as mobiles, smart phones and phablets, does have all the universal apps from the home edition as well as touch centric Office app. It does support continuum to use their phone like a pc if the device meets the hardware requirements
Windows 10 Pro
Desktop editon for desktops, laptops, tablets and 2-in-1s. Has many extra features built on top of home edition and is suitable for small business. Will have support for the new Windows Update for Business which helps to reduce management costs, controls over updates installation and offers quicker access to security updates.
Windows 10 Enterprise
Ideal for medium and large businesses, available for Volume Licensing customers, supports Windows Update for Business and have access to Long Term Servicing Branch as a deployment option
Windows 10 Education
Built on top of Enterprise version, designed to meet the needs of schools and various academic institutions, available through Academic Volume Licensing
Windows 10 Mobile Enterprise
Designed for business customers on smartphones and phablets, available for Volume Licensing Customers, offers great productivity, security and device management capabilities and flexible ways to manage updates.
Windows IoT Core
Designed for small footprint, low cost devices like gateways
There will also be seperate versions of Windows 10 Enterprise and Windows 10 Mobile Enterprise for devices like ATMs, POS, Handheld Terminals and Industrial Robotics
Breaking Changes coming your way for ASP.NET Core 3.0
Resilient Connections in Entity Framework Core