Tuesday, 8 October 2013

C# Versions and features

These are the known versions of C#

  • Visual Studio 2013: No new C# and VB Language Features in VS 2013. But it has new versions of .NET Framework and ASP.NET i.e. .NET Framework 4.5.1 and ASP.NET 4.5.1. Click here to see what is new in VS 2013
  • C# 5.0 released with .NET Framework 4.5 and Visual Studio 2012 (August 2012). Major features: Asynchronous Programming with async and await, caller info attributes.
  • C# 4.0 released with .NET Framework 4 and Visual Studio 2010 (April 2010). Major new features: late binding (dynamic), delegate and interface generic variance, more COM support, named arguments and optional parameters
  • C# 3.0 released with .NET Framework 3.5 and Visual Studio 2008 (November 2007). Major new features: LINQ (Language Integrated Query), lambda expressions, extension methods, expression trees, anonymous types, implicit typing (var), One-step object creation and initialization, One-step collection creation and initialization, Type Inference, Automatic properties, Func and Action generic delegates
  • C# 2.0 released with .NET Framework 2.0 and Visual Studio 2005 (November 2005). Major new features: generics, anonymous methods, nullable types, iterator blocks
  • C# 1.2 released with .NET Framework 1.1 and Visual Studio 2003 (April 2003).
  • C# 1.0 released with .NET Framework 1.0 and Visual Studio 2002 (January 2002)

Click here to read about ASP.NET MVC Versions and Features

New features in C# 6

New features in C# 5

Microsoft Visual Studio on Wiki

.NET Framework versions and Dependencies

http://csharpindepth.com/Articles/Chapter1/Versions.aspx

Monday, 7 October 2013

When does microsoft stop supporting IE7?

Support for Internet Explorer versions are tied to the support for the OS it shipped with. The latest OS shipped with IE7 is Windows server 2008 and support for that will continue until end of 2018.

IE7 has only about 10% of the browser market share

Microsoft support life cycle

ie7-expected-end-of-support

Friday, 4 October 2013

Build XML Site Map online

www.xml-sitemaps.com helps you to create an XML sitemap that can be submitted to Google, Bing, Yahoo and other search engines to help them crawl your website better.

You can also generate an HTML site map to allow human visitors to easily navigate on your site.

Tuesday, 1 October 2013

How to print part of rendered html page?

This can be done using CSS and JavaScript as well. See examples below.

Print part of the page using CSS

To do it using CSS you need to apply @media specific styles to page content which you want to print and non-printable stuff.

<html>
<head>
    <style type="text/css">

    #printable { display: none; }

    @media print
    {
     #non-printable { display: none; }
     #printable { display: block; }
    }
    </style>
</head>
<body>
    <div id="non-printable">
     Your normal page contents
    </div>

    <div id="printable">
     Printer version
    </div>
</body>
</html>

Print part of the page using JavaScript

To achieve the same functionality using JavaScript you need to use an iframe and set it's innerHTML based on what you want to print.
<html>
<head>
<title>Print Test Page</title>
<script>

function printDiv(divId) {
    window.frames["print_frame"].document.body.innerHTML=
       printDivCSS + document.getElementById(divId).innerHTML
    window.frames["print_frame"].window.focus()
    window.frames["print_frame"].window.print()
}
</script>
</head>
<body>
<b>Div 1:</b> <a href=javascript:printDiv('div1')>Print</a><br>
<div id=div1>This is the div1's print output</div>
<br><br>
<b>Div 2:</b> <a href=javascript:printDiv('div2')>Print</a><br>
<div id=div2>This is the div2's print output</div>
<br><br>
<iframe name=print_frame width=0 height=0 
frameborder=0 src=about:blank></iframe>
</body>
</html>

Thursday, 1 August 2013

LINQ Basics

LINQ (Language Integrated Query, pronounced "link") is a Microsoft .NET Framework component that adds native data querying.)

Linq is the Microsoft's first attempt to integrate queries into language. We know, it is really easy to find data from sql objects simply writing a query while its somewhat hectic when we want to do the same thing in a DataTable or Lists. Generally we will have to loop through every elements to find the exact match, if there is some aggregation we need to aggregate the values etc. Linq provides an easy way to write queries that can run with the in memory objects.

Linq provides an easy way to write queries that can run with the in memory objects.

Example: (from item in itemlist where item.value = somevalue select item).toList();

Types of LINQ

    Linq comes with 3 basic types (Provided there are lots of more types of LINQ on different type of objects :

  1. LINQ (Linq to Objects)

    Linq To Objects - examine System.Linq.Enumerable for query methods. These target IEnumerable, allowing any typed loopable collection to be queried in a type-safe manner. These queries rely on compiled .Net methods, not Expressions.

  2. DLINQ (Linq to SQL)
  3. XLINQ (Linq to XML)

LINQ Operators

  • Restriction Operator
    Where
  • Projection Operator
    Select
  • Partition Operators
    Take, Skip, TakeWhile, SkipWhile
  • Ordering Operators
    OrderBy, OrderByDescending, ThenBy, ThenByDescending, Reverse
  • Grouping Operators
    GroupBy
  • Set Operators
    Distinct, Union, Intersect, Except
  • Conversion Operators
    ToArray, ToList, ToDictionary, OfType
  • Element Operators
    First, FirstOrDefault, ElementAt
  • Generation Operators
    Range, Repeat
  • Quantifiers
    Any, All
  • Aggregate Operators
    Count, Sum, Min, Max, Average, Aggregate
  • Miscellaneous Operators
    Concat, EquallAll
  • Custom Sequence Operators
    Combine
  • Query Execution
    Deferred, Immediate, Query Reuse
  • Join Operators
    Cross Join, Group Join, Cross Join with Group Join, Left Ounter join

101 LINQ Samples
http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b

LINQ to Objects

http://www.codeproject.com/KB/dotnet/LINQ.aspx

http://www.codeproject.com/KB/cs/InsideAnonymousMethods.aspx

What is Language-Integrated Query - LINQ?

LINQ Query Expressions

Wednesday, 31 July 2013

?? Operator in C#

The ?? operator is called the null-coalescing operator and is used to define a default value for nullable value types or reference types. It returns the left-hand operand if the operand is not null; otherwise it returns the right operand.

A nullable type can contain a value, or it can be undefined. The ?? operator defines the default value to be returned when a nullable type is assigned to a non-nullable type. If you try to assign a nullable value type to a non-nullable value type without using the ?? operator, you will generate a compile-time error. If you use a cast, and the nullable value type is currently undefined, an InvalidOperationException exception will be thrown.

int? x = null;
// y = x, unless x is null, in which case y = -1. 
int y = x ?? -1;

Useful links

Nullable Types

?? Operator

The C# ?? null coalescing operator (and using it with LINQ)

Wednesday, 24 July 2013

Windows Keyboard Shortcuts

Calculator Keyboard Shortcuts

Press this key To do this
Press this key

Alt+1

To do this

Switch to Standard mode

Press this key

Alt+2

To do this

Switch to Scientific mode

Press this key

Alt+3

To do this

Switch to Programmer mode

Press this key

Alt+4

To do this

Switch to Statistics mode

Press this key

Ctrl+E

To do this

Open date calculations

Press this key

Esc

To do this

Press the C button

Full list is available here
http://windows.microsoft.com/en-gb/windows/keyboard-shortcuts#keyboard-shortcuts=windows-7