C#

Using Math.Pow Method to Compute Exponents in C#

If you require to compute exponential values like finding the square of the number etc , the Math.Pow method in c# could be handy for you to try . The Math.Pow method is defined in the “System” namespace . To use the method “Math.Pow” , you should first include the namespace System using System; The Math.Pow accepts 2 parameters number to be raised to a power number that specifies a power Read More....

Be the first to comment - What do you think?
Posted by Senthil Kumar - January 14, 2012 at 6:42 pm

Categories: C#   Tags: , ,

Using Aggregate Function on Arrays in C#

If you have got an array of integers and you want to multiple the values inside the array and display its value without using for loop  , here’s one of the ways to achieve it using the LINQ and Lambda expression . Assuming the array of integer has the following values int[] marks = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; You can multiply each of the values inside the integer array without using any for loop or fo Read More....

Be the first to comment - What do you think?
Posted by Senthil Kumar - January 5, 2012 at 10:30 pm

Categories: C#, Entity Framework   Tags: , ,

How to order by multiple columns using Lambas and LINQ in C# ?

Today , i was required to order a list of records based on a Name and then ID . A simple one but i did spend some time on how to do it with Lambda Expression in C# . C# provides the OrderBy,OrderByDescending,ThenBy,ThenByDescending . You can use them in your lambda expression to order the records as per your requirement . Assuming your list is “Phones” and contains the following data … public clas Read More....

4 comments - What do you think?
Posted by Senthil Kumar - December 23, 2011 at 7:31 pm

Categories: C#, Entity Framework   Tags: , ,

How to convert HexaDecimal Number to Decimal , Octal and Binary Number using C# ?

This is my fouth and last post of the series of the Number Converter for Windows Phone 7 sourcecode . In my previous posts i talked about How to convert Octal Number to Decimal , HexaDecimal and Binary Number using C# ? Number Converter for WP7 – How to convert Decimal Number to Binary , HexaDecimal and Octal Number using C# ? How to convert Binary Number to Decimal , HexaDecimal and Octal Number using C# ? In Read More....

2 comments - What do you think?
Posted by Senthil Kumar - September 13, 2011 at 10:09 pm

Categories: .NET, C#, Windows Phone 7   Tags: , , , , , ,

3 ways to Sort in Descending order via lambdas

In C# , one can sort the List of Objects using Lambdas easily . Until now , i found the LINQ Query to be more easy to sort but after using the Lamba expression , i feel that the lambda expression can also be used effectively to sort in descending order . For example , i use the below class for the data public class Movie { public string MovieName { get; set; } public string Actor { get; set; } } public class Read More....

8 comments - What do you think?
Posted by Senthil Kumar - September 10, 2011 at 8:16 pm

Categories: .NET, C#   Tags: , , , , , ,

How to convert Octal Number to Decimal , HexaDecimal and Binary Number using C# ?

This is my third post of the series of the Number Converter for Windows Phone 7 sourcecode . In my previous posts i talked about Number Converter for WP7 – How to convert Decimal Number to Binary , HexaDecimal and Octal Number using C# ? How to convert Binary Number to Decimal , HexaDecimal and Octal Number using C# ? In this blog post , i describe or share the code  that converts a Octal Number to Decimal , H Read More....

5 comments - What do you think?
Posted by Senthil Kumar - September 6, 2011 at 11:10 pm

Categories: .NET, C#, Windows Phone 7   Tags: , , , ,

How to convert Binary Number to Decimal , HexaDecimal and Octal Number using C# ?

This is my second post of the series of the Number Converter for Windows Phone 7 sourcecode . In my previous post i talked about Number Converter for WP7 – How to convert Decimal Number to Binary , HexaDecimal and Octal Number using C# ? In this blog post , i describe or share the code  that converts a Binary Number to Decimal , HexaDecimal and Octal Number using C# in Windows Phone 7 . public static class Bi Read More....

8 comments - What do you think?
Posted by Senthil Kumar - August 31, 2011 at 9:59 pm

Categories: .NET, C#, Windows Phone 7   Tags: , , ,

Using Face API in C#

Face.com provides an face recognition API that offers the developers and publishers to automatically detect and recognise faces in photos using robust , free REST API . This was one of the API that we used during the Yahoo OpenHack India 2011 for our App called “Face the Music” . The application developed captures the human emotion (facial expression) via the webcam and plays the music based on the emot Read More....

1 comment - What do you think?
Posted by Senthil Kumar - August 2, 2011 at 11:44 pm

Categories: .NET, C#   Tags: , , , , ,

How to retreive the list of files from Directory in C# ?

Here’s a simple example that gets all the file names from a given directory . The Directory class defined in the System.IO namespace provides the static GetFiles method that retreives all the file names with the complete path in the directory . The below will retreive all the files names along with its complete path from C:\temp private void Form1_Load(object sender, EventArgs e) { string[] lstFiles = Di Read More....

1 comment - What do you think?
Posted by Senthil Kumar - June 30, 2011 at 8:52 pm

Categories: .NET, C#   Tags: , , , ,

Creating ConnectionString with SqlConnectionStringBuilder Class in C#

The SqlConnectionStringBuilder was introduces in .NET 2.0 that is used to build the database connection string specific for the SQL Server . The MSDN defines it as “Provides a simple way to create and manage the contents of connection strings used by the SqlConnection class. ” The SqlConnectionStringBuilder is defined in the namespace System.Data.SqlClient and can help you build the connection string or Read More....

4 comments - What do you think?
Posted by Senthil Kumar - May 27, 2011 at 11:33 pm

Categories: .NET, C#   Tags: , ,

How to fill a string with repeated characters in C# ?

Here’s a small tip on using the string class better . You can use the string class constructor to fill a string that has all the repeated characters . For example , assume you want a string with 10 # or * symbols . One of doing this declaring a string like this string str = “##########”; The other easy and best way is to use the string class constructor like below private void Form1_Load(object se Read More....

1 comment - What do you think?
Posted by Senthil Kumar - May 21, 2011 at 11:29 pm

Categories: .NET, C#   Tags: , , , ,

Anonymous Type Differs in C# and VB.NET

Have you Observed anonymous types closely in c# as well as VB.NET ? Check the below sample sourcecode In VB.NET  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         Dim PersonData As New Dictionary(Of String, Integer)         PersonData.Add("Ilayathalapathy Vijay", 51)         PersonData.Add("Ultimate Star Ajithkumar", 49)       Read More....

Be the first to comment - What do you think?
Posted by Senthil Kumar - May 8, 2011 at 6:05 pm

Categories: .NET, C#, vb.net   Tags: , , , , , , , , ,

BigInteger in C# 4.0

When talking to one of my friend today , he mentioned about the BigInteger data type in Java . I was wondering what this datatype equivalent be in C# and ended up to see this datatype in C# too . This is available in C# 4.0 . The BigInteger represents a large signed integer where its value has no upper or lower bounds so that it can be used on operation on very large values   To use the BigInteger in C# , one migh Read More....

2 comments - What do you think?
Posted by Senthil Kumar - April 23, 2011 at 10:34 pm

Categories: .NET, C#   Tags: , , , , ,

String vs string in c#

How do you create a string variable in c# ? String ? string ? Confused with the above text . Well its just that we use either the keyword string or we use String . Is both String and string same in C# ? string is just an alias name for the class System.String which means both has the same functionalities .The IL code generated for both of them is also same . Note that string is a keyword , but String isn’t wh Read More....

5 comments - What do you think?
Posted by Senthil Kumar - April 12, 2011 at 11:29 pm

Categories: .NET, C#   Tags: , , , , ,

Using Implicit Method Group Conversion in C#

Its great to learn something everyday that keeps me updated in .NET which always makes me feel fresh . With every topic that i come across everyday , it make me feel that i am still a fresher . Today , i got to know something about Implicit Method Group Conversion in C# . Well , if you are still looking to know whet it is , the example below will clearly explain you this . Assume that the List contains the Names Se Read More....

6 comments - What do you think?
Posted by Senthil Kumar - March 21, 2011 at 9:44 pm

Categories: .NET, C#   Tags: , , , , , , , , ,

How to mark a method as Obsolete or Deprecated in C# ?

How can you mark a function or a method as deprecated in c# ? . You can do it in c# using the obsolete attribute . For Example : public class Employee { public string Name { get; set; } public void SetEmployeeName(string name) { Name = name; } } If you need to mark the method SetEmployeeName as deprecated , then , just include the obsolete attrbute before the functio Read More....

3 comments - What do you think?
Posted by Senthil Kumar - February 6, 2011 at 3:32 pm

Categories: .NET, C#, Visual Studio 2010, Windows Application   Tags: , , ,

3 uses of the @ Symbol in c#

1. You can use one of the reserved words of c# with the @ symbol Eg : string @int = "senthil kumar"; or something like this string @class ="MCA"; Although you can use this , avoid using one. 2. Before a string specially when using the file paths . You can use string filepath = @"D:\SENTHIL-DATA\myprofile.txt"; instead of string filepath = "D:\\SENTHIL-DATA\\myprofile.txt"; 3. For a Multi lined text strin Read More....

8 comments - What do you think?
Posted by Senthil Kumar - January 24, 2011 at 9:34 pm

Categories: .NET, C#, Visual Studio 2010, Windows Application, Windows Phone 7   Tags: , , ,

default keyword in c#

The “Default” keyword in c# can be used in the following scenarios . The main use of default comes in to picture when used in the generic code. 1. To return Type’s Default Value The Default returns the type’s default value. For the Integer , it returns 0 , for Boolean , it returns false and for the reference types , it returns null int valueI = default(Int32); bool ValueB = default(Boolean) Read More....

6 comments - What do you think?
Posted by Senthil Kumar - January 21, 2011 at 9:06 pm

Categories: .NET, C#, Visual Studio 2010, Windows Application   Tags: , , , ,

Why doesn’t this cause an Exception ?

I was trying to run the below code snippet in Visual Studio 2010 . int Number1 = 320000; int Number2 = 320000; int Number3 = Number1  * Number2 ; MessageBox.Show(Number3.ToString()); The code resulted in the value – 797966336 without being showing the error or the correct value . Just found that If you want an exception to be raised on this occassion , then use the following 2 options Read More....

1 comment - What do you think?
Posted by Senthil Kumar - January 18, 2011 at 8:52 pm

Categories: .NET, C#, Visual Studio 2010, Windows Application, Windows Phone 7   Tags: , , ,

Nullable DateTime and Ternary Operator in C#

Just Recently when i was working on a solution to assign Null values to the Datetime , i was struck up for some time in doing this though the solution was simple . I had to cast to the right type ( Nullable of Datetime ) . The stuff that i was doing was assigning a value null directly to the variable when used with the Ternary or coascalence operator . This post talks about the different ways of assigning the null Read More....

2 comments - What do you think?
Posted by Senthil Kumar - January 13, 2011 at 11:50 pm

Categories: C#, Visual Studio 2010   Tags: , , , , , ,

Reference Highlighting in Visual Studio 2010

In the Visual Studio 2010 , when we select a variable , all the instances of the variables are highlighted automatically . This works similar to FindAll .. giving the developer a clear overview of the instances used in the form by highlighting the selected text/ variable  . If you don’t like this feature and want to disable it , here’s are the steps to be followed . Go to Tools Select Options Click Te Read More....

3 comments - What do you think?
Posted by Senthil Kumar - December 14, 2010 at 10:19 pm

Categories: .NET, C#, Visual Studio 2010   Tags: , , , , , , , ,

Dotnet Developers – Did u notice the Google talk Plugin installer ???

Well , it we only recently that i noticed how the installation of google talk plugin inside the Gmail works . Well , the installation had some interesting information for .NET Developers . Just check the Installation screenshots that i took below . Well , It has the similar concept and the UI as the Click Once Deployment in .NET ) ClickOnce deployment makes things easier for installing the Application  for all Read More....

1 comment - What do you think?
Posted by Senthil Kumar - November 5, 2010 at 11:10 pm

Categories: .NET, ASP.NET, C#, Others, Visual Studio 2010, Windows Application   Tags: , , , , , , ,

.First() throws Error in LINQ or Entity Framework Queries

I use .First() method in some of the Entity Framework LINQ queries to return only one record . This works perfectly similar to the select Top 1 statemnent in SQL . Eg : var data = (from m in Employees     where m.Name == "Senthil"     select m).First() But , there is an issue with this . Assume your LINQ Query does not contain any Records or the SQL Statement ( TOP 1 ) does not return any records . What would Read More....

3 comments - What do you think?
Posted by Senthil Kumar - November 3, 2010 at 11:16 pm

Categories: .NET, C#, Entity Framework, Visual Studio 2010, Windows Application   Tags: , , , , , ,

Free Programming Windows Phone 7 ebook is now Available

Here’s a free ebook written by Charles Petzold, one of the famouus author on Developing for Windows Phone 7  . The book is titled “Programming Windows Phone 7″ and is from Microsoft Press . The book contains 24 chapters and about 1000 pages .. You can download the ebook in the PDF format here . Kick start the WP7 Development with this useful ebook . Read more at MSDN Blog here. Read More....

Be the first to comment - What do you think?
Posted by Senthil Kumar - October 30, 2010 at 8:06 pm

Categories: .NET, C#, Visual Studio 2010, Windows Phone 7   Tags: , , , ,

More training videos of Windows Phone 7 for Developers

I had posted some links of the Videos on Windows Phone 7 Jumpstart Videos in my earlier posts … Windows Phone 7 Jumstart Sessions – Training Videos now Available Free Training on Windows Phone 7 Advanced Topics Part1 and Part2 Here comes some more links for the new videos posted and more topics are covered in the new videos that include Panorama & Pivots, Planning & Optimizing for Performance, De Read More....

1 comment - What do you think?
Posted by Senthil Kumar - October 28, 2010 at 11:25 pm

Categories: .NET, C#, Visual Studio 2010, Windows Phone 7   Tags: , , , , , , ,

Not supported in LINQ to Entities and Entity Framework ..

I was forced to explore something interesting when i was playing around with the Entity Framework and executing the below LINQ query. EmployeeEntities entityContext = new EmployeeEntities(); var Records = (from m in entityContext.Employees   Select m).LastOrDefault(); My assumption was that the result would be the last record in the table .. But to my surprise , it threw an Exception LINQ to Entities does not re Read More....

5 comments - What do you think?
Posted by Senthil Kumar - October 25, 2010 at 10:13 pm

Categories: .NET, C#, Entity Framework, Visual Studio 2010   Tags: , , , , , , , , , ,

Windows Phone Developer Tools October 2010 Update

With in few weeks after the Windows Phone 7 launch , Microsoft has released an update for the Developer tools for Developing Windows Phone 7 Applications . For installing the october update ,the developers should be running the RTM / Final version of the Windows Phone Developer Tools. The October 2010 Update includes two new utilities like Windows Phone Capability Detection Tool The tool performs the detection p Read More....

Be the first to comment - What do you think?
Posted by Senthil Kumar - October 22, 2010 at 10:34 pm

Categories: .NET, C#, Visual Studio 2010, Windows Phone 7   Tags: , , , , , , , ,

Caught up with Bugs in My Favourite IDE ( Visual Studio 2010 )

Well , for the last few months i have been facing some serious issues in running Visual Studio 2010  as a result of some error messages / bugs . Here are some of the messages / bugs that i was able to capture .For some of the problems i was able to find the fix/update from the Microsoft Connect website , but for others i am still hunting for one  . 1. Catastrophic failure Puzzled , puzzled and Puzzled . Dont Read More....

3 comments - What do you think?
Posted by Senthil Kumar - October 19, 2010 at 9:25 pm

Categories: .NET, C#, Entity Framework, Visual Studio 2010, Windows Application   Tags: , , , , , , , , , , , ,

Stepping out of my Comfort Zone

Just a few days back , i came across the blog post by Davy Brion on "You Need To Step Out Of Your Comfort Zone" . Well an Excellent article by Davy . David talks about the upside and the downside of his experience and thoughts on “instead of learning a lot of languages, wouldn’t it better to really focus on one and know it very thoroughly?” ....

Read more...

4 comments - What do you think?
Posted by Senthil Kumar - October 3, 2010 at 11:04 pm

Categories: .NET, C#, Entity Framework, General, Personal, Visual Studio 2010   Tags: , , , , , , , , , , , , ,

Using Array.ConvertAll to Convert an array of one type to another in C#

Thanks to one of My friend (Anil pai) , who asked me a question on how to convert a string array to an float/Double Array which made me to explore the possibilities in .NET and this is when i came across Array.ConvertAll The usual way of doing this is to parse and convert each values one by one like this ..

Read more...

1 comment - What do you think?
Posted by Senthil Kumar - September 5, 2010 at 7:16 pm

Categories: .NET, C#, Visual Studio 2010, Windows Application   Tags: , , , , , ,

Next Page »

© 2011-2012 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