Month: September 2015

Boxing and Unboxing


Boxing: Implicit conversion of a value type (int, char etc.) to a reference type (object), is known as Boxing. In boxing process, a value type is being allocated on the heap rather than the stack.

  • It converts a value type into a reference type.
  • Values are stored in the Stack first then moved to the heap.
  • Creates a container/box for holding the value.

Unboxing: Explicit conversion of same reference type (which is being created by boxing process); back to a value type is known as unboxing. In unboxing process, boxed value type is unboxed from the heap and assigned to a value type which is being allocated on the stack.

  • It is the opposite process of boxing.
  • It converts an object type back into the value type.
  • It is an explicit operation using C-style casting.

Example

namespace BoxingUnboxing
{
    class Program
    {
        static void Main(string[] args)
        {
            int Val = 1;
            Object Obj = Val;		//Boxing
            int i = (int)Obj;		//Unboxing
            Console.WriteLine("Boxing: {0}", Obj);
            Console.WriteLine("Unboxing: {0}", i);
            Console.ReadLine();
        }
    }
}

Note:

Sometimes boxing is necessary, but you should avoided it if possible, since it will slow down the performance and increase memory requirements.
For example, when a value type is boxed, a new reference type is created and the value is copied from the value type to the newly created reference type. This process takes time and required extra memory (around twice the memory of the original value type).

Advertisements

Apple Watch Users Can Now Use Google Map


Apple watch New Google map update was released by Google this Tuesday. The new iOS update makes Google app compatible on Apple watch. Now Apple watch users can easily use Google map.

When you open the Google map app on your watch, you will be presented with the option, which allows you to easily navigate to work and home. The direction to your work place and home is already preset, by using your Google account.

route from home to work

Google map also offers some other features, such as; it can estimate time of arrival, made by car, bikes, public transit as well as by walking. You will also be able to make business calls while looking at the direction, and also get direction from a list of places.

You can now download this app from Apple’s App Store.

Value Type and Reference Types


typesinnetThe Types in .NET Framework are either treated by Value Type or by Reference Type. A Value Type holds the data within its own memory allocation and a Reference Type contains a pointer to another memory location that holds the real data. Reference Type variables are stored in the heap while Value Type variables are stored in the stack.

Value Types

value_typeA Value Type stores its contents in memory allocated on the stack. When you created a Value Type, a single space in memory is allocated to store the value and that variable directly holds a value. If you assign it to another variable, the value is copied directly and both variables work independently. Predefined datatypes, structures, enums are also value types, and work in the same way. Value types can be created at compile time and Stored in stack memory, because of this, Garbage collector can’t access the stack.

Examples : int, enum, structs.  

(more…)

Microsoft launches a new query language, U-SQL


Microsoft announced a new query language called U-SQL to work with big data. The language was announced as a part of Microsoft’s new Azure Data Lake service. Azure Data Lake service is a new analytics service built on YARN that allows data scientists to analyze data. It works with Microsoft’s Azure HDInsight, a fully managed Hadoop, Spark, Storm and HBase service. U-SQL takes advantage of SQL query syntaxes.

Visual Studio blog team wrote a blog on the reason U-SQL was developed and what are the advantages of U-SQL.

“Taking the issues of both SQL-based and procedural languages into account, we designed U-SQL from the ground-up as an evolution of the declarative SQL language with native extensibility through user code written in C#. This unifies both paradigms, unifies structured, unstructured, and remote data processing, unifies the declarative and custom imperative coding experience, and unifies the experience around extending your language capabilities.

U-SQL is built on the learnings from Microsoft’s internal experience with SCOPE and existing languages such as T-SQL, ANSI SQL, and Hive. For example, we base our SQL and programming language integration and the execution and optimization framework for U-SQL on SCOPE, which currently runs hundred thousands of jobs each day internally. We also align the metadata system (databases, tables, etc.), the SQL syntax, and language semantics with T-SQL and ANSI SQL, the query languages most of our SQL Server customers are familiar with. And we use C# data types and the C# expression language so you can seamlessly write C# predicates and expressions inside SELECT statements and use C# to add your custom logic. Finally, we looked to Hive and other Big Data languages to identify patterns and data processing requirements and integrate them into our framework.”

U-SQL was developed to process any type of data. Not only U-SQL scales efficiently to any size of data but also allows data developers to use custom code easily to express your complex, often proprietary business algorithms.

Rounded Corners Using CSS3


With the CSS3 border-radius property, you can give any element “Rounded Corners“.

css3Here is the code:

<!DOCTYPE html>
<html>
<head>
<style> 
#rcorners1 {
    border-radius: 25px;
    background: #8AC007;
    padding: 20px; 
    width: 200px;
    height: 150px;    
}
#rcorners2 {
    border-radius: 25px;
    border: 2px solid #8AC007;
    padding: 20px; 
    width: 200px;
    height: 150px;    
}
#rcorners3 {
    border-radius: 25px;
    background: url(paper.gif);
    background-position: left top;
    background-repeat: repeat;
    padding: 20px; 
    width: 200px;
    height: 150px;    
}
</style>
</head>
<body>
The border-radius property allows you to add rounded corners to elements.
Rounded corners for an element with a specified background color:
Rounded corners!
Rounded corners for an element with a border:
Rounded corners!
Rounded corners for an element with a background image:
Rounded corners!
</body>
</html>

Check Live Demo Here : Rounded Corners Using CSS3

Hello World Using AngularJs


Simple AngularJs Hello World Program.

AngularJS Reference

AngularJS library written in JavaScript. Angular js reference file is given below.

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>

Here is the complete code :

<!DOCTYPE html>
<html>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>

<div ng-app="">
Input something in the input box:
Name : <input type="text" ng-model="name" placeholder="Enter name here">

<h1>Hello {{name}}</h1>

</div>

</body>
</html>

Output :

angularjs1

Check Live Demo Here : Hello World Using AngularJs

Google Voice Search Now More Accurate And Faster


Nowadays, we use Google Search result for almost everything. Some of us use Voice Search to avoid the tiring task of typing with “Ok Google“. To make things easier for these users, the search engine giant has enhanced the voice search for accuracy and speed.

Google Speech Team stated via a blog post:

“We are happy to announce that our new acoustic models are now used for voice searches and commands in the Google app (on Android and iOS), and for dictation on Android devices. In addition to requiring much lower computational resources, the new models are more accurate, robust to noise, and faster to respond to voice search queries – so give it a try, and happy (voice) searching!”

The team further explained that now they’ve now built better neural network acoustic models using Connectionist Temporal Classification and sequence discriminative training techniques to upgrade its voice search functionality.

These neural network acoustic models are a special extension of recurrent neural networks (RNNs) that are more accurate, especially in noisy environments, and are faster.

From here you can use the improved voice search tool on Android and iOS.