Var keyword in Delphi/Oxygene and C#

I had the privilege of working on some of the interesting languages like Delphi, Oxygene, C# etc.

All the languages listed above has the keyword var which worked slightly different in each of the languages.

In Delphi and Oxygene, one can use var keyword to pass the parameter by reference as well as to start the block of variable initialization within the method.

method MainForm.Function1;


message1 : String;


message1 := "Welcome to";

load(var message1);



method MainForm.load(var data: String);


data := "This is a test application";


In C#, the var keyword denotes an anonymous type. When you want to assign a variable, you need not specify the type but instead specify it as var, C# finds out what is the resulting type. One of the most common use of the var keyword in C# is in the LINQ query.

Check the 5 Things That You Cannot do with a Local Type Inference In C# to know more about var keyword in C#

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Reply


Interesting BlogPosts to read

How to get an Enumerator from range of elements from ArrayList in C# ?
The code snippet shown in this blog post demonstrates how you can get the enumeraor from a range of ...
How to check for the column name in an SqlDataReader Object in C# ?
When working in ADO.NET for data access , there are times when you want to check to see if a column ...
How to convert Array to List in C#?
Want to convert array of strings to List of strings in C# ? . Below is a sample code to illustrate t...