Using Math.Pow Method to Compute Exponents in C#
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....Categories: C#, Entity Framework Tags: Aggregate Function, c#, LINQ
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....Categories: C#, Entity Framework Tags: c#, lambda, LINQ
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....Categories: .NET, C#, Windows Phone 7 Tags: binary, converter, Decimal Number, Hexa decimal, octal, Windows Phone 7, WP7
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....Categories: .NET, C# Tags: .NET, c#, Descending order, lambda, LINQ, Query, vsiual studio 2010
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....Categories: .NET, C#, Windows Phone 7 Tags: .NET Framework, c#, Number Converter, Windows Phone 7, WP7
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....Categories: .NET, C#, Windows Phone 7 Tags: c#, convert, number, Windows Phone 7
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....Categories: .NET, C# Tags: c#, Face API, Gender, Mood, Visual Studio, Yahoo OpenHack
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....Categories: .NET, C# Tags: c#, microsoft, Visual Studio
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....Categories: .NET, C# Tags: c#, microsoft, repeated characters, tip, Visual Studio 2010
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....Categories: .NET, C#, vb.net Tags: Anonymous Type, c#, differences, Ilayathalapathy Vijay, microsoft, readonly, superstar, Ultimate Star, VB.NET, Visual Studio 2010
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....Categories: .NET, C# Tags: BigInteger, C# 4.0, microsoft, MSDN, System.Numerics, Visual Studio
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....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....Categories: .NET, C#, Visual Studio 2010, Windows Application Tags: c#, Deprecated, Obsolete, Visual Studio
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....Categories: .NET, C#, Visual Studio 2010, Windows Application, Windows Phone 7 Tags: c#, microsoft, Symbol, Visual Studio
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....Categories: .NET, C#, Visual Studio 2010, Windows Application Tags: c#, default, Generic Code, keyword, switch
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....Categories: .NET, C#, Visual Studio 2010, Windows Application, Windows Phone 7 Tags: Checked Block, OverFlow Exception, project, Visual Studio 2010
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....Categories: C#, Visual Studio 2010 Tags: c#, Datetime, Nothing, null, Nullable, Ternary Operator, VB.NET
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....Categories: .NET, ASP.NET, C#, Others, Visual Studio 2010, Windows Application Tags: .NET, Click Once, Developers, dotnet, google, installation, Kindle, Plugin
.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....Categories: .NET, C#, Entity Framework, Visual Studio 2010, Windows Application Tags: Entity Framework, Error, First, FirstOrDefault, LastOrDefault, LINQ, Top
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....Categories: .NET, C#, Visual Studio 2010, Windows Phone 7 Tags: Charles Petzold, MSDN, Programming Windows Phone 7, Windows Phone 7, WP7
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....Categories: .NET, C#, Entity Framework, Visual Studio 2010 Tags: .NET, c#, Entity Framework, expression, LastOrDefault, LINQ, LINQ to Entities, MSDN, SQL, store, Visual Studio 2010
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....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....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 ..
Categories: .NET, C#, Visual Studio 2010, Windows Application Tags: .NET, Anil pai, Array, c#, ConvertAll, mscorlib.dll, System
