Technology News

August 24, 2007

C# 3.0 – What’s New : {Implicit}-Part1

Filed under: C# 3.0, Code, First, Tips — చక్రవర్తి @ 10:52 am

Recent development in my technical life is that, started working out with Orcas Beta 2. So, thought to blog about the latest happenings with C# language. The idea emerged to start a series of posts related to C# new features. This is the first of ever such kind of blogging specific to a topic.

C# 3.0 has many-a-new features. To start with, let me take a concept of Implicitly Typed Variables.

Implicitly Typed Variables

In the good old days, the developer has to worry about the type of the variable. Say for instance, whether to use long or double for a counter. Here all that we observe is that the language that is built upon is the type specific. Hence forth the developer is not required to define the type of the variable at the time of declaration, but it is the task of the compiler to decide what type of the object the variable is. All that the developer has to do is that, use the var keyword while declaring the variable, similar to that of JScript or Visual Basic style. Hey!!! Stop!!!!! don’t get confuse with the type of VAR variables declared at JScript or Visual basic.

Let’s first discuss the difference between VAR variables at JScript and VAR variables of C#

VAR JScript VAR C#
This is of no type The type of the variable is defined by the value declared and decided at the compile time
Technically have no type. Can consider of limited types, namely, string literal, numeric, boolean Type agnostic, have specific predefined formats
Type conversion is coercion Type casting is simple and handled by CLR
No mechanism for parsing explicit functions for parsing to specific type

Now, let us see the difference between the language specific VAR of VisualBasic 6.0 and C# 3.0

VAR in VB (but not .NET) VAR in C# 3.0
By definition, these are Variant Type of the variable is defined at the compile time
Could be any allowed type from with in the known types of the language Type is decided by the value associated with the variable
Largest among all the known data types Size depends on the type of the value initialised

To summarize, the variables declared in C# 3.0 are type specific, thou used the key word VAR, during the declaration. Thus, we can conclude that the compiler is the responsible point to decide the type of the variable. Hence we can say with comfort that, the variables from C# 3.0 are Implicitly Typed variables.

Some examples as mentioned below.

            var vIntVal = 10; // This will be the System.Int32 type
            var vLongVal = 10000000000; // This will be the System.Int64 type
            var vDoubleVal = 10.0; // This will be the System.Double type
            var vFloatVal = 10.0f; // This will be the System.Single type
            float vFlVal = 10.0f; // Thou defined using float key word, but inherits from Struct System.Single 
            var vStrVal = "String Value ";  // This will be the System.String type

So, from the above declarations, it is pretty clear that the variable is defined by the value associated during the declaration. The type is not just limited to the kind of data types as explained above, but you can extend this to any type of the variable that you use while writing code for iterations, similar such as foreach. Below is the example for other known types.

            foreach (var vTable in ds.Tables) // Implicitly declared a variable of Data Table Type
            {
                foreach (var vRow in ((DataTable) vTable).Rows) // Implicit declaration of DataRow variable
                {

                }
            }

By using such, one can extend any extent. The limit is the imagination of the developer. What do you say?

Source:

1) http://cobdev.cob.isu.edu/psb/jscript/306.htm for JScript
2) http://www.1sayfa.com/1024/diger/vb/ch07.htm for Visual Basic 6.0 Datatypes

del.icio.us Tags: , , , ,

August 6, 2007

Save Power by using Google in Black

Filed under: Google, Save Energy — చక్రవర్తి @ 3:37 pm

Would like to bring this to your attention that, while searching at Google you could save some energy. Would you like to know ?How??, read further, not interested !!! Just Move on to next message.

Consider that you query at Google.com (with White background as it is by default). And white pixels as full background will consume 74 watts. You seek some info at Google, and the search results remain on your screen for more than 10 seconds.

The statistics from Google states that an approximate hit count for a day is at around 200 Million, that means there are about such huge number of people who are hitting Google by default with White Background. Resulting to consume the energy of 74 watts with every user. For your information on general CRT, the white pixels consume 74 watts, where as the black pixels consume at about 59 watts. So when you calculate mathematically, you would save about 15 watts, when compared to white background with black, causing lots of saving at the radiation from CRTs, Cathode Ray Tubes. But this is not true with LCD Screens, Liquid Crystal Display Screens. The LCDs will consume the same amount of energy when compared to both Black and White.

So, for the fact of figures, if 200 Million people use Black background Google instead of White background, estimate how much power saving??? And one more thing, you might not have all the 200 Million hits from the system that is attached with CRT Screens. When practically speaking, we see more CRT display screens than LCD screens. Hence request you to save energy, as an old saying echo?s in my mind as, ?A penny saved is a penny earned?. In similar, ?Energy saved is Energy Produced?

The alternatives for ?White Background Google? is ..

1) 07designs.com/gdark => This has some script that will install as browser plugin

2) Searchincolors.com => You can search in any color that you like for Google.com, as background, foreground, blah, blah,..

3) Godark.us => has many other features, I recommend this due to the extra features

4) Jabago.com => thou not high funda, but meaningful

5) Ninja.com => simple to remember

6) Google-black.blogspot.com => You can write your own Google, as this blog. Inspire from this blog, can you create one such??

7) Trek3d.com/black => what are your comments on this???

Finally, any other recommendations towards ?Googling in Black??

Technorati Tags: ,

August 4, 2007

Posting from Laptop

Filed under: First — చక్రవర్తి @ 10:37 pm

This is the first time am posting from laptop. This laptop is provided by my employer, let’s see how this will increase my blogging attitude.

Create a free website or blog at WordPress.com.