Tag: C#
Cast Operator with Anonymous Types
Below is a sample sourecode that demonstrates the usage of the Cast Operator when using the anonymous type Cast Operator with Anonymous Types When the element within the List cannot be converted to the target type, you will receive an exception “InvalidCastException”.
How to select top 5 records from List using LINQ in C#?
Below is a sample code snippet demonstrating on how to select top 5 records from a list using LINQ in C# using the Take extension method… How to select top 5 records from List using LINQ in C#?
How to write a byte array to a File in C# ?
If you want to write a byte array to a file in C# , you can use the File.WriteAllBytes . Below is a code snippet demonstrating this. How to write a byte array to a File in C# ?
How to find if 2 Objects are Equal in C#?
There are times when you need to determine if 2 objects are equal or not. In these cases, you could either override the Equals method or implement IEquatable interface. How to find if 2 Objects are Equal in C#? Below is a sample code snippet demonstrating the usage of Object.Equals method to find the equality of 2 objects.
How to fill an array with default values in C# ?
To fill an array with the default values in C# , you can use the Enumerable.Repeat method to do it. How to fill an array with default values in C# ? Below is a sample code illustrating the usage of the Enumerable.Repeat method to fill an array with default values.
Posting Data to a URL using WebClient in C#
Below is a sample code snippet demonstrating the usage of the WebClient to post data to the server in C#. How to Post data to a URL using WebClient in C# ?
How to Save an Appointment in Windows Phone 8 using C# ?
If you want to allow the user to create or save an appointment within the Calendar application in Windows Phone 8 , you can do it using the SaveAppointmentTask launcher. How to Save an Appointment in Windows Phone 8 using C# ? To use the SaveAppointmentTask launcher , first enable the ID_CAP_APPOINTMENTS in the WMAppManifest file. Create an instance of the SaveAppointmentTask class and set…
Best Java Equivalent for LINQ (C#)
LINQ Query and Lambda expressions are one of the popular features of C# which helped the .NET developers in many ways. If you are a Java developer and wondering is there anything similar to this in Java ? ,this post will provide some insights on the additional APIs which could bring in the similar functionality Best Java Equivalent for LINQ (C#) jaque Another Java integrated…
How to Create a Unique temporary file in C# ?
There are times when you want to create an unique temporary file in C# to deal with the storage of the data. In this case , you can use the Guid Name to get the unique name. How to Create a Unique temporary file in C# ?
C# Program to find the ASCII Value of a Character
Problem Write a program in Visual C# to find the ASCII value of the input character. How to find the ASCII value of a character in C# ? Output Abundantcode.com coding sample Enter a character : A 65
How to read a connection string from web.config file in ASP.NET ?
Assume that you have a connectionstring configured in the web.config file of your ASP.NET application and you wish to read it using C# within your application. How to read a connection string from web.config file in ASP.NET ? You can easily do that using the ConfigurationManager class defined in the System.Configuration namespace. 1. Ensure that the System.Configuration assembly is referenced in your project. 2. Add…
How to download a file from a URL using C#?
You can use the WebClient class in C# to download a file. How to download a file from a URL using C#? Here’s a code snippet demonstrating how you can download a file using the instance of the WebClient class in C#.