Menu

Posts tagged "c#"

Jump Start Series – Advanced Windows Store App Development using C#

Here's another Jump Start Series on Windows Store App Development but this time with some advanced topics on the Store App Development Using C# which is targeted for the intermediate to advanced learners and lets the developers prepare for Microsoft Certification exam MCTS 70-485 . The Advanced Windows Store App Development Read More →

7 Libraries for Reading and Writing from/to Excel File in C#

Few months back , I was making an R&D on the possibilities of reading and writing to/from the Excel file from .NET (C#) . At that point of time , I came across various libraries and SDK's available for Reading and Writing from Excel File in Read More →

How to return Dictionary as result from a LINQ Query in C# ?

This article will provide a code snippet and explains how to return Dictionary as result from a LINQ Query in C#. There are times when you want to retrieve only the ID(distinct) and the name from the database table using LINQ . In scenarios like this , one can use the Read More →

Difference between Any() and Count() in LINQ

Most of the developers would have come across Any() and Count() when using LINQ in C# . What is difference between Any() and Count() in LINQ ?

Difference between Any() and Count() in LINQ

Assume , you want to know if the collection contains records based on some criteria and you Read More →

Using Lambda Expression and LINQ to Concatenate strings in C#

Learnt something cool today on how to use Lambda expression and LINQ to concatenate string in C#.

Using Lambda Expression and LINQ to Concatenate strings in C#

There are couple of ways which I explored using today for concatenating string using LINQ . It includes the usage of the Select function but Read More →

SingleOrDefault vs. FirstOrDefault in LINQ

The LINQ (Language Integrated Query) has the extension methods SingleOrDefault and FirstOrDefault . What is the difference between SingleOrDefault and FirstOrDefault in LINQ. In one of my previous blog post , I wrote about .First() throws Error in LINQ or Entity Framework Queries which explains the use of Read More →

Remove All Objects matching the condition from a List using LINQ in C#

Are you using LINQ in C# and requite to remove all objects matching the condition from a List ? Read this blog post to find out how to delete all objects matching the condition from a List using LINQ.

How to Remove all the objects matching the condition from a Read More →

Using the operator AND in LINQ

Recently , I had received an query from one of my blog readers asking the question related to SQL and LINQ .
"In SQL , we can use AND operator when checking for multiple conditions , what is the equivalent of AND in LINQ in c#" ?
This is a simple one Read More →

LIKE operator in LINQ

Does the LINQ(Language Integrated Query) have the LIKE operator like the one we have in the SQL Server or any other databases ? I have been searching for similar function in LINQ and below are some of the ways which you could bring in the functionality of the LIKE operator in Read More →

What is the difference between IEnumerable and IQueryable in C# ?

If you are a C# developer and work with collections as well as LINQ/Entity Framework , you would have come across these 2 interfaces
  • IEnumerable
  • IQueryable

What is the difference between IEnumerable and IQueryable in C# ?

1. IEnumerable is used mostly for working with in-memory collection data where as IQueryable suits Read More →

Using Multiple Order By Clause in LINQ and Lambda Expression (C#)

The orderby keyword can be used in LINQ to retrieve the ordered list of records based on the specified field. For example to order the list of movies , one might use the orderby as shown below in the LINQ query
var moviesLinq1 = (from m in movies
orderby m.Actor
select m).ToList();

How to Read More →

How to provide a default value for a Auto-Implemented Properties in C# ?

In C# , when you are using an Auto-Implemented Properties , you can use the constructor of the class to set the default value for that property. For example ,
class Movie 
{
    public Movie()
    {
        MovieName = Read More →           

DebuggerDisplay Attribute in C#

The DebuggerDisplay is useful to quickly view the customized output of a class which in turn can display more meangful text during debugging. Below is an example. Assume the class Student contains the following properties
class Student

{

   public string Name {get;set;}
   public string RegNo {get;set;} 
}
An instance Read More →

Merge 2 DataTables in C# and ASP.NET

The Merge() method of the datatable is used to Merge a datatable (second datatable) and stores the result to the first datatable. For example , assume the following datatables are present EmployeeDataTable1 and EmployeeDataTable2 . If you want to merge the data from EmployeeDataTable2 to EmployeeDataTable1 , you could do something like Read More →

How to cast integer to Enum in C# ?

This is a really simple one . Below is a simple example of an enum called "Designation" defined with the values Trainee,SoftwareEngineer,Architect.
enum Designation
{
Trainee,
SoftwareEngineer,
Architect
}
We can cast the integer value to the enum (Designation) like the way shown below.
Designation design = (Designation)2;
There are other ways by which you can cast Read More →

Mono 3.0 Released

A new version of Mono v3.0 is released and is now available for download from the mono project website.

What is Mono?

Mono is an open source implementation of the .NET Framework and is available for UNIX, Windows, MacOS, openSUSE, Solaris etc. Mono 3.0 now has the complete C# 5.0 compiler Read More →

How to Log off Windows programmatically using C# ?

How to Log off from Windows programmatically using C# ?

Below is a simple program that lets you to Log off Windows programmatically using C# . The P/Invoke's ExitWindowsEx method is used to Log off from Windows using C# .
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{  
  Read More →           

What is Property Value Inheritance – XAML ?

When you created a new Windows Phone App , you would have noticed the following in the MainPage.XAML's PhoneApplicationPage  element .
 FontFamily="{StaticResource PhoneFontFamilyNormal}"
 FontSize="{StaticResource PhoneFontSizeNormal}"
 Foreground="{StaticResource PhoneForegroundBrush}"
The above sample code is an example of the Property Value Inheritance which indicates the default appearance of the child elements of the page Read More →

How to Loop through or Iterate over all Enum Values in C# ?

Sometimes , it may be necessary for the C# developers to loop through or iterate over all the Enum Values in solving a particular task. In this blog post , i will explain with an example on How to Loop through or Iterate over all Enum Values in C# ? We Read More →

Difference between the out and ref keyword in C#

To pass an argument by reference in C# , we use the keyword ref . There is also another keyword "out" which can also be used to pass an argument by reference . Below is a sample code demonstrating the usage of the out and ref keyword.
class Employee
{
   Read More →           

© 2011-2013 Senthil Kumar's Blog This is my personal blog .The opinions expressed here represent my own and not those of my employer . All Rights Reserved -- Copyright notice by Blog Copyright