Category: C#

Lambdas Expression for Getter-Only Auto-Properties in C# 6.0

C# 6.0 lets the developers use the lambda expression to implement the getter value of the read-only property . Whenever a lambda expression is found , the C# compiler identifies it as the property with only get method rather than a field. Lambdas Expression for Getter-Only Auto-Properties in C# 6.0 Below is a sample code snippet demonstrating the use of Lambdas Expression for Getter-Only Auto-Properties…

C# Compiler Warning – CS8371 field-targeted attributes on auto-proper

In this blog post, you’ll learn more about the C# Compiler Warning – CS8371 and the related message description C# Compiler Warning Code CS8371 C# Compiler Description for the Code :CS8371 Field-targeted attributes on auto-properties are not supported in language version {0}. Please use language version {1} or greater.

How to Notify Clients when there is a change using C# ?

There are times when you want the users who use the class wants some kind of indication or notification when there is a change in data inside it . One of the solutions for this is to make the class implement INotifyPropertyChanged interface which is located in the namespace System.ComponentModel. One of the primary use of the INotifyPropertyChanged is in the WPF / Silverlight /…

C# Compiler Error – CS8361 a conditional expression cannot be used

In this blog post, you’ll learn more about the C# Compiler Error – CS8361 and the related message description C# Compiler Error Code CS8361 C# Compiler Description for the Code :CS8361 A conditional expression cannot be used directly in a string interpolation because the ‘:’ ends the interpolation. Parenthesize the conditional expression.

How to Catch an Exception in C# ?

Every time when the exception is thrown , it is necessary that it be handled . In this case , one needs to wrap the code with the try catch block as shown below. How to Catch an Exception in C# ?

Will the Windows Phone 7 App run on Windows Phone 8 Devices?

This is one of the most frequently asked question by any newbie windows phone developer. Will the developed Windows Phone 7 App run on Windows Phone 8 Devices? The answer to this pretty simple and straight forward. Yes, in most cases, the Windows Phone 7 app will run fine on Windows Phone 8 devices. But the only drawback here is that the apps targeting the…

How to Convert Integer to Hex and Vice versa in C# ?

If you want to convert an integer value to a hexa decimal value in C# and hexa decimal value to integer , you can use the “X” string formatting specifiers and the int.parse method with the method over loading option. How to Convert Integer to Hex and Vice versa in C# ? The code snippet to demonstrate the conversion of the integer value to hexa…

How to Validate an email address using Regular Expression in C# ?

You can validate an email address in C# using regular expressions which provides the developers to play around with different patterns. Below is a code snippet that shows how you can use regular expression to validate an email address in C# . How to Validate an email address using Regular Expression in C# ?