Merge Two Arrays – The LINQ Way

I just came across a requirement of  merging two arrays of integers. So I already had this integer array and there was a new array of same type and required merging those two. Yep remove any duplicates as well.

Line 4 of the Code

It just says add idList2 to idList1 and remove of any duplicates and convert the output to an array. In this case to an Integer array.

Output Window

Output Window

Happy Coding !!! 🙂

Choosing an ASP.net Flavour

At the beginning there was only ASP.net Web Forms. Now you have three different models to choose with.

  1. ASP.net Web Forms
  2. ASP.net MVC
  3. ASP.net Web Pages

ASP.net Web Forms

These are set of pages that has a UI (User Interface), Server Controls and Server Code. When a user sent a request to the page using the browser, it goes to the server,  then compiled and executed at the server side. Finally generates HTML markup that can be rendered on your browser. If you are a experienced Windows Forms developer its a good choice to choose Web Forms. It is the event driven world that you already familiar with.

Server Controls such as Button, Grids, Labels, DropDowns can be easily dragged and dropped to your design and start coding like you did with Windows Forms.   To write server code to handle the logic for the page, you can use a .NET language like Visual Basic or C#.

More details on ASP.net Web Forms

ASP.net MVC

The MVC stands for Model View Control. This is a design pattern most developers are familiar with. This is a light weight framework that can be used with ASP.net features such as Membership based authentication and Master Pages. This pattern separates your application into three parts. The logic of the application goes under Model. The presentation layer goes under View and finally talking between model and the presentation layer goes under Controller. Again to write code and handle the logic you can use a .NET language like Visual Basic or C#.

More details on ASP.net MVC 

ASP.net Web Pages

This flavour gives you a taste of script based programming like you did with classic ASP or PHP. A special syntax called Razor will escape your HTML code to dynamic code using a .NET language like Visual Basic or C#. If you know HTML, CSS and little bit of JavaScript and you have programmed with a .NET language like Visual Basic or C# and you are ready to start building ASP.net Web Pages.

More details on ASP.net Web Pages 

Have a Good Day !!! 🙂

How do I print “1” as “0001” ?

Yep, a nice little question. Some of you may have wondering how to do that. In my database ID field it says “1” (or any integer value) on my Web Page or Windows Form I need to print this as “0001”. Do we have a simplest method to do that? And the answer is (drum roll) ….. YES ..

OK, next question what does this format specifier “D” means. Here is the MSDN help about it.

The “D” (or decimal) format specifier converts a number to a string of decimal digits (0-9), prefixed by a minus sign if the number is negative. This format is supported only for integral types.

The precision specifier indicates the minimum number of digits desired in the resulting string. If required, the number is padded with zeros to its left to produce the number of digits given by the precision specifier. If no precision specifier is specified, the default is the minimum value required to represent the integer without leading zeros.

Also we can use another string method known as . Lets have a look on that code.

allows you to apply any character (type of Char) as the leading character. In this case ‘0’

Have Fun 🙂