Posted by triaslama on June 24, 2008
I think its quite interesting if we compare two things that has equalities and differences. Now we will talk about Forms (WebForms and WinForms).
As we already know WebForms uses browser as presentation (ASP.NET Forms is no exception) and Windows Forms has its own presentation. So we may agree that WebForms has the strength through its availability and WinForms through its rich user interface.
In this post I will talk about the differences, what I get from both forms (ASP.NET Forms and Windows Forms) at a glance. I hope this post not tedious for those who already familiar with ASP.NET and Windows Forms.
Base Class
An ASP.NET Form inherits Page class (contained in System.Web.UI namespace). Look at the following example:
Presentation page (Welcome.aspx):
<%@ Page Language=”C#” debug=”true” CodeFile=”Welcome.aspx.cs” Inherits=”Welcome.HelloWorldClass” %>
<html>
<head>
<title>Welcome To ASP.NET Form</title>
<script lang=”C#” runat=”server”>
</script>
</head>
<body>
<form runat=”server”>
<center><asp:Label id=”label” Font-Size=”25px” style=”font-weight:bold;” runat=”server” /></center>
</form>
</body>
</html>
This is the code behind (Welcome.aspx.cs):
Read the rest of this entry »
Posted in .NET, ASP.NET, C#, Programming | Tagged: ASP.NET, Desktop, Forms, Web, Windows Forms | No Comments »
Posted by triaslama on May 27, 2008
C# 3.0 brings many of new features. Some of features developed from the existing one (such as lambda expressions that provides more concise syntax than anonymous methods). Other features can be considered as totally new (such as LINQ). In this post together we will learn about Inferred type variables, extension methods, and lambda expressions.
By reading this article I assume that you are familiar with C#, knowing the previous features of this language is a plus.
Inferred Type Variable
Inferred type variable presented through ‘var’ keyword. If you are a Javascript programmer you must be already familiar with ‘var’ keyword. But, ‘var’ in C# 3.0 has different meaning with ‘var’ keyword in Javascript. In C# 3.0 when we use ‘var’, we tell the compiler that the type of variable should be inferred from the assignment. In Javascript var means that a variable can hold any kind of type.
Consider the following Javascript file:
var myVariable = 5;
window.alert(myVariable);
myVariable = “I change the type of myVariable, now myVariable is a string!”;
window.alert(myVariable);
At the beginning I assign myVariable with 5 (an integer), but later, I assign myVariable with a string (so myVariable can hold any kind of value). But its not the case with ‘var’ in C# 3.0.
using System;
class InferredTypeVar
{
static void Main()
{
var myVariable = 12.5;
Console.WriteLine("myVariable: "+myVariable);
}
}
Because I assign 12.5 to myVariable then type of myVariable will be double. If we try to fake the compiler and add the following code (hoping that it will the same as in Javascript):
Read the rest of this entry »
Posted in C# | Tagged: C# 3.0, Extension Methods, Inferred Type Variables, Lambda Expressions | 4 Comments »