Category: C#

C# Compiler Error – CS0151 a switch expression or case label must b

In this blog post, you’ll learn more about the C# Compiler Error – CS0151 and the related message description C# Compiler Error Code CS0151 C# Compiler Description for the Code :CS0151 A switch expression or case label must be a bool, char, string, integral, enum, or corresponding nullable type in C# 6 and earlier.

How to Open External Link using Hyperlink Control in Windows Phone 8?

The HyperLinkButton provides one of the easiest way to navigate to an external link without using the WebBrowserTask in Windows Phone 8. Below is a sample code snippet demonstrating how to use the HyperLinkControl to open external link in Windows Phone 8. How to Open External Link using HyperLinkControl in Windows Phone 8? Note that you need to specify the Target name to _blank for…

Displaying data in flat list in Windows Phone 8 LongListSelector Control

Below is a sample code snippet demonstrating the display of the flat list in the Windows Phone 8 LongListSelector Control. Displaying data in flat list in Windows Phone 8 LongListSelector Control LongListSelector Declaration <phone:LongListSelector Name=”lstWebsites” HorizontalAlignment=”Left” VerticalAlignment=”Top” LayoutMode=”List” IsGroupingEnabled=”False” Width=”446″> <phone:LongListSelector.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text=”{Binding Name}” /> </StackPanel> </DataTemplate> </phone:LongListSelector.ItemTemplate> </phone:LongListSelector> Model public class WebsiteName { public string Name { get; set; } public int…

How to remove the non ascii characters from a string in C# ?

Regular expression comes in handy especially if you want to remove the non ascii characters from a string in C#. Here’s a regular expression sample in C# demonstrating how to do it. How to remove the non ascii characters from a string in C# ? The output of the code snippet will be cde in C#

Programmatically Go Back to Previous Page in Windows Phone App

The developers can use the NavigationService.GoBack method to navigate to the previous page of the Windows Phone App. When using the NavigationService.GoBack , it is necessary to check if the Navigation can go back using the property NavigationService.CanGoBack as shown below. Programmatically Go Back to Previous Page in Windows Phone App