Nullable Type in C#

Nullable type in C#
We can declare a variable as nullable when we want to know that a value has been assigned to that variable or not. Declaring a variable as nullable enables the HasValue and Value members. We can use the HasValue property on the variable to check if the value has been assigned to the variable.

Example of Using Nullable
Let’s take an example of boolean variable. As we know the default value for a boolean variable is false. But we want that we should be able to know if user has selected true or false. So we define the bool variable as nullable like this:

Nullable<bool> testVariable= null;

Now we have the testVariable as a boolean variable having a value of null. Now when use the properties like this :

MessageBox.Show(String.Format("Value is {0}",testVariable.value )); 

kick it on

Shout it

pimp it

.NET and J2EE. Status as of now and scope in future.(Updated with important note)

Big question today: What is the scope of .NET and J2EE platforms. Which one is more dominant in industry today?

I want to answer this question in this post with my viewpoint with no intentions of hurting anybody but with a sole intention of increasing the knowledge of J2EE for .NET people and .NET for the J2EE people
and being a developer in Microsoft technologies i agree my opinion may be aligned towards .NET but what i sincerely want is that through this platform i want to know the actual status of the platforms viz a viz features and invite everybody to add to my learning the new things happening in the J2EE world as well.

On Technology Front
I think that with the arrival of Mono, the only disadvantage that .NET had over J2EE platform i.e of platform independence has been resolved up to an extent. But with the introduction of WCF, WPF, Workflow Foundation, LINQ, ASP.NET MVC framework, Silverlight,ASP.NET Ajax and many such other features have only added to the popularity as well as usefulness of .NET both for programmers, designers and enterprises. With .NET 4.0 parallel programming framework, improved WCF and host of improvements along with Visual studio 2010 will be a great advantage for all..NET 4.0 will also be integrating cloud computing platforms. You will agree to the fact that coupling of IIS and SQL Server is superb in terms of performance as compared to any other options.

Today designers and developers can work together on the tool provided by Microsoft and the UI can be deployed to Web,Desktop or Mobile with an assurance of same effects.
I think JAVA have been left far behind on the technology terms as compared to .NET over past few years as I have not come across any such features being introduced in J2EE platform.

What customers want is fast development of the solution at low cost, and if we start of with .NET we can develop the solution at a very fast rate, thanks to the host of tools provided by Microsoft, and then use cloud computing to bring down the IT costs.You get .NET resources fast as well ,thanks to initiatives taken by Microsoft to teach students and the interest they are able to generate within the students community.

I believe that with the launch .NET 3.5 and onwards, there no looking back for .NET platform as it has enabled the developers to provide good quality extensible code at a fast rate to clients taking the full advantage of the latest operating systems plus giving the backward compatibility to most applications previously built on .NET platform. What more can customers ask for?

I also believe that yes J2EE is also here to stay for a long time as it also has got a big customer base but to compete with the .NET platform they need to pick up fast and offer some features which Microsoft has already done with, to at least get back into competition with .NET

Important NOTE:
I am in NO WAY attached to Microsoft except for the fact that i am a .NET developer and get excited with all the new things happening in the technology world and due to my busy schedule i am not able to keep myself updated on Java. So i started off with my little knowledge of the features i have about .NET and invite everybody here to discuss and put forward the corresponding features from J2EE platform. That’s it. It is of minimal importance for me as which of J2EE or .NET is more popular but what matters is i should know tomorrow that if i want to do something how is that possible with the help of two options and which one fits the best in that situation and what other features can we expect from both the fronts in the near future
I would request you not to comment as in way of showing down J2EE or .NET as i will delete those comments.

Constructive Comments are most welcome.

kick it on

Shout it

pimp it

Anonymous Constructor in C#

C# 3.0 introduced a very compact way of initializing objects of a class.

Previously we used to initialize objects like this:

MailMessage mailMessage = new MailMessage();
            mailMessage.Body = message;
            mailMessage.BodyEncoding = Encoding.GetEncoding(UIConstants.NewAccountMailBodyEncoding);
            mailMessage.From = new MailAddress(UIConstants.Me2AdminEmail);

Now, with the new feature known as Anonymous Constructors or Object Intializers we can do the same code in C# 3.0 and above like this:

 MailMessage mailMessage = new MailMessage()
                Subject = UIConstants.UIErrorSubject,
                Body = message,
                BodyEncoding = Encoding.GetEncoding(UIConstants.NewAccountMailBodyEncoding),
                From = new MailAddress(UIConstants.Me2AdminEmail)

In the C# 3.0 code, there is no constructor that corresponds to the way I instantiated the object. This prevents developers from having to create a different constructor for each different set of properties that need to be set. It also make the code easier to read.

kick it on

Shout it

pimp it