LINQ to XML in a Nutshell

Data may exist in much form. You may have data in relational tables residing on a relational database or portable data in form of XML. Since data exist in many forms, obviously there are many ways to manipulate or access them. One of the most popular ways of sharing data is as XML.

Considering prominent presence of XML as way of data sharing, LINQ to XML got introduced in C# 3.0 to work effectively and efficiently with XML data. LINQ to XML API contains classes to work with XML. All classes of LINQ to XML are in namespace System.XML.Linq.

image

Objective of this article is to understand, how could we work with LINQ to XML?

Let us start with below image. It depicts an isomorphic relationship between XML elements and cross-ponding LINQ to XML classes.

image

XML Element is fundamental XML constructs. An Element has a name and optional attributes. An XML Elements can have nested Elements called Nodes also.

XML Element is represented by XElement class in LINQ to XML. It is defined in namespace System.Xml.Linq. And it inherits the class XContainer that derives from XNode. Below tasks can be performed using XElement class

  • It can add child element.
  • It can delete child element.
  • It can change child element.
  • It can add attributes to an element.
  • It can be used to create XML tree
  • It is used to serialize the content in a text form

XElement class got many overloaded constructors. You can pass XAttribute to create XML elements with attribute.

If you examine below code snippet, I am creating XML with root element Root and many child elements. Child Element Data1 and Data2 got attributes name and ID respectively with value Dj and U18949

Code Listing 1


XElement xmltree = new XElement("Root",
new XElement("Data1", new XAttribute("name", "Dj"), 1),
new XElement("Data2", new XAttribute("ID", "U18949"),
new XAttribute("DEPT","MIT"),2),
new XElement("Data3", "3"),
new XElement("Data4", "4")
);
Console.WriteLine(xmltree);

On executing above code you should get below output,

image

Let us stop here and examine how Attributes of XML is mapped in XAttribute of LINQ to XML. XML Attribute is a Name/Value pair associated with XML elements. XAttribute class represents XML Attributes in LINQ to XML. XAttribute class is overloaded with two constructors. Most frequent used constructor is one takes name and values as input parameter. In CodeListing1 , attributes to element is being created using XAttribute class.

A XML tree can be constructed using XAttribute and XElement class.

Assume you have a list of Authors as below code listing, Author is a custom class.

Code Listing 2


static List<Author> CreateAuthorList()
{
List<Author> list = new List<Author>()
{
new Author(){Name="Dhananjay Kumar",NumberofArticles= 60},
new Author (){Name =" Pinal Dave ", NumberofArticles =5},
new Author () {Name = " Deepti maya patra",NumberofArticles =55},
new Author (){Name=" Mahesh Chand",NumberofArticles = 700},
new Author (){Name =" Mike Gold",NumberofArticles = 300},
new Author(){Name ="John Papa",NumberofArticles = 200},
new Author (){Name ="Shiv Prasad Koirala",NumberofArticles=100},
new Author (){Name =" Tim  ",NumberofArticles =50},
new Author (){Name=" J LibertyNumberofArticles =50}
};
return list;
}

<strong></strong>

class Author
{
public string Name { get; set; }
public int NumberofArticles { get; set; }
}

XML tree can be constructed from List of Authors as below code listing,

Code Listing 3


List<Author> list = CreateAuthorList();

XElement xmlfromlist = new XElement("Authors",
from a in list
select
new XElement("Author",
new XElement("Name", a.Name),
new XElement("NumberOfArticles", a.NumberofArticles)));

<strong></strong>

xmlfromlist.Save(@"e:\\a.xml");

<strong></strong>

Above code snippet will create Authors as root element. There may be any number of Authors as child element inside root element Authors. There are two other elements Name and NumberOfArticles are in XML tree.

There may be scenario when you want to create XML tree from a SQL Server table. You need to follow below steps,

  1. Create Data Context class using LINQ to SQL class
  2. Retrieve data to parse as XML
  3. Create XML tree
  4. Create elements and attributes using XElement and XAttribute
  5. WCF is name of table.

Code Listing 4


DataClasses1DataContext context = new DataClasses1DataContext();
var res = from r in context.WCFs select r;

XElement xmlfromdb = new XElement("Employee",
from a in res
select
new XElement("EMP",
new XElement("EmpId", a.EmpId),
new XElement("Name", a.Name)));

&nbsp;

xmlfromlist.Save(@"e:\\a.xml");

<strong></strong>

By this point you know various ways of constructing XML tree and saving on file system. Now next thing come to your mind would be how to parse XML files using LINQ.

Parsing of XML document means reading XML document, identifies the function of each of the document and then makes this information available in memory for rest of the program. XElement.Parse () method is used to parse XML. This is an overloaded method. This takes a string input parameter to parse. Second overloaded method takes extra input parameter LoadOptions. LoadOption defines where to preserve space in information or not?

Below code snippet is parsing a string with space preserve.

Code Listing 5


&nbsp;

&nbsp;

XElement xmltree = XElement.Parse(@"<Address><Name>Dhananjay Kumar </Name> <Road> Padma Road </Road> </Address>",LoadOptions.PreserveWhitespace);
Console.WriteLine(xmltree);

After knowing all the pieces of LINQ to XML, let us go ahead and find how we could put all information we have so far to bind information from XML file to DataGrid of Silverlight. It is a common requirement when you need to bind or display data from XML File to Silverlight Data Grid.

Essentially there are three steps you need to execute to bind XML to Silverlight Data Grid.

  1. Download content of XML file as string using WebClient class.
  2. Parse XML file using LINQ to XML
  3. Bind parsed result as item source of Data Grid.

Very first you need to prepare XML file as data source. Put XML file in bin folder of Silverlight project. However you can parse XML file from remote location as well.

We are going to bind Data.xml residing in client bin folder to Data Grid.

Code Listing 6


<?xml version="1.0" encoding="utf-8" ?>
<School>
<Student RollNumber="1" Name="John Papa" />
<Student RollNumber="2" Name="Scott Gui" />
<Student RollNumber="3" Name="Jessy Liberty" />
<Student RollNumber="4" Name="Tim Huer" />
<Student RollNumber="5" Name="Victor G" />
<Student RollNumber="6" Name="Mahesh Chand" />
<Student RollNumber="7" Name="Pinal Dave" />
<Student RollNumber="8" Name="Suprotim Agarwal" />
<Student RollNumber="9" Name="Dhananjay Kumar" />
<Student RollNumber="10" Name="Kunal Chawudhary" />
<Student RollNumber="11" Name="Abhijit Jana" />
<Student RollNumber="12" Name="Shiv Prasad Koirala" />
</School>

Next task you need to design XAML page. I am keeping it simple and putting a Button and DataGrid . On click event of button datagrid will be bind with data from xml file.

Xaml design would look like below code snippet.

Code Listing 7


<Grid x:Name="LayoutRoot" Background="White">
<StackPanel Orientation="Vertical" Margin="50,50,50,50">
<Button x:Name="btnDemo" Content="Click To get Data From  XML File" Height="62" Width="362" />
<sdk:DataGrid x:Name="grdXmlData" Height="Auto" Width="Auto" AutoGenerateColumns="True" />
</StackPanel>
</Grid>
</UserControl>

On click event of button, make an asynchronous call and download the file.

Code Listing 8


&nbsp;

private void btnDemo_Click(object sender, RoutedEventArgs e)
{
WebClient client = new WebClient();
Uri uritoXML = new Uri("Data.xml", UriKind.Relative);
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
client.DownloadStringAsync(uritoXML);

}

&nbsp;

Once string is downloaded, you need to parse the downloaded XML.

Code Listing 9


void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{

if (e.Error != null)
{
MessageBox.Show("There is Error Downloading Data from XML File ");
}
else
{

ParseXMLFile(e.Result);
}
}

&nbsp;

XML can be parsed as below. On examining below code, you will find XML file is loaded using XDocument. After loading file is being traversed using Descendants method. On getting the values for each Student node, you need to create instance of Student and add it to the list of Student.

Code Listing 10


&nbsp;
void ParseXMLFile(string  dataInXmlFile)
{

lstStudents = new List<Student>();

XDocument xmlDoc = XDocument.Parse(dataInXmlFile);
lstStudents  = (from r in xmlDoc.Descendants("Student")
select new Student
{
Name = (string) r.Attribute("Name").Value,
RollNumber =(string) r.Attribute("RollNumber").Value
}).ToList();

grdXmlData.ItemsSource = lstStudents;


}

Explanation

  1. Function is taking string as input parameter. Here we will pass e.Result from Downloadcompletedstring event.
  2. Creating an instance of XDocument by parsing string
  3. Reading each descendants or element on Xml file and assigning value of each attribute to properties of Entity class (Student).

We need to create an Entity class to map the data from XML File. I am going to create a class Student with properties exactly as the same of attributes of Student Element in XML file.

Student class is listed as below,

Code Listing 11

public class Student
{

public string RollNumber { get; set; }
public string Name { get; set; }

}

On running you should get the expected output.

Assume you have data in XML file as below. This file is save in location d drive.

Data.Xml


<?xml version="1.0" encoding="utf-8" ?>
<catalog>
<books>
<book id="bk101">
<author id="1">Gambardella, Matthew</author>
<title>XML Developer’s Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description> An in-depth look at creating applications with XML.</description>
</book>
<book id="bk102">
<author id="2">Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description> A former architect battles corporate zombies,an evil sorceress, and her own childhood to become queen of the world.</description>
</book>
<book id="bk103">
<author id="3">Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-11-17</publish_date>
<description>After the collapse of a nanotechnology society in England, the young survivors lay the foundation for a new society. </description>
</book>

<book id="bk104">
<author id="4">Corets, Eva</author>
<title>Oberon’s Legacy</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2001-03-10</publish_date>
<description>In post-apocalypse England, the mysterious agent known only as Oberon helps to create a new life for the inhabitants of London. Sequel to Maeve Ascendant.</description>

</book>

<book id="bk105">
<author id="5">Corets, Eva</author>
<title>The Sundered Grail</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2001-09-10</publish_date>
<description>The two daughters of Maeve, half-sisters, battle one another for control of England. Sequel to Oberon’s Legacy.</description>

</book>
</books>
</catalog>

To fetch all the Books, just you need to parse the XML file. Find the descendants book and fetch it in anonymous class.


XDocument document = XDocument.Load("D:\\Data.xml");
#region Fetch All the Books
var books = from r in document.Descendants("book")
select new
{
Author = r.Element("author").Value,
Title = r.Element("title").Value,
Genere = r.Element("genre").Value,
Price = r.Element("price").Value,
PublishDate = r.Element("publish_date").Value,
Description = r.Element("description").Value,

};

foreach (var r in books)
{
Console.WriteLine(r.PublishDate + r.Title + r.Author);
}

&nbsp;

If you want to fetch a particular book, you need to apply where condition while parsing XML file.


var selectedBook = from r in document.Descendants("book").Where
(r=>(string)r.Attribute("id")=="bk102")
select new
{
Author = r.Element("author").Value,
Title = r.Element("title").Value,
Genere = r.Element("genre").Value,
Price = r.Element("price").Value,
PublishDate = r.Element("publish_date").Value,
Description = r.Element("description").Value,

};

foreach (var r in selectedBook)
{
Console.WriteLine(r.PublishDate + r.Title + r.Author);
}

&nbsp;

You need to fetch author Id of a particular book with Id bk102. To do that you need to select as below,

var selectedBookAttribute = (from r in document.Descendants("book").Where
(r => (string)r.Attribute("id") == "bk102")
select r.Element("author").Attribute("id").Value).FirstOrDefault();

Console.WriteLine(selectedBookAttribute);

&nbsp;

To fetch the entire author name, you need to execute below query.


var allauthors = from r in document.Descendants("book")
select r.Element("author").Value;
foreach(var r in allauthors)
{
Console.WriteLine(r.ToString());
}

&nbsp;

I hope this article was useful. Thanks for reading Smile

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

Creating Style Rules in HTML 5

In this post, we will see the way to create Style Rules in HTML 5.

Style is a rule we apply to tags

  1. These rules {style} can be applied to individual instance of tags.
  2. These rules {style} can be applied to all instances of a particular tag within a document.
  3. These rules {style} can be applied to all instances of particular tag within a group of document.

To create Style Rules you have three options as depicted in below diagram

image

Constructing Style

To construct a Style to be used in the same document, you need to follow below steps

You have to put <style></style> in head section of the document. Notice that in HTML 5, you do not need to provide any type of the style.

 

clip_image001

 

If you want to create rule for tag H1 then you can create it as below. If you notice tag is not within the bracket

 

clip_image002

You can set more than one rule for a tag in same style rule. For example if you want to set color and font size as well. Then you will have to separate both rules by the semicolon

 

clip_image003

If you want to apply same rule to more than one tag , you can very much do that by separating all tags by comma

clip_image004

If you apply above created style and use tag h1 then you will get html page rendered as below,


<!DOCTYPE html>
<html >
<head>
<title>
HTML5
</title>
<style>
h1,h2,h3
{
color:Red ;
}
</style>
</head>
<body>
<h1>Hello HTML 5</h1>
</body>
</html>

Expected rendering would be as below,

image

Constructing Style for Nested Tags

Sometime you may have requirement to put certain style rules to tags when they are nested in other tags. For example; you want to make UL as square if it is nested inside an OL. You can very much do that in HTML 5 as below,

image

 

You can apply rules to tags nested to any level. For example if you want to apply h1 tag inside a ul tag and ul tag is inside ol then you can apply very much like below,

image

In below HTML , rules [color red] being applied to tag h1 nested inside ol and ul . whereas there is no rule for usual h1.


<!DOCTYPE html>
<html >
<head>
<title>
HTML5
</title>
<style>
ol ul h1
{
color:Red
}
</style>
</head>
<body>
<h1>Hello HTML 5</h1>
<ol>
<li> One </li>
<li>Two
<ul>
<li>
<h1>Two A </h1>
</li>
</ul>
</li>
</html>

&nbsp;

When you view in browser above HTML you will get expected rendering as below. Please notice that “Hello HTML 5” text is rending with usual h1 whereas TWO A is in the color red.

image

Creating Classes and Id for Style

So far we are creating rules for a particular tag and setting it as style. There may be scenario where you do not want to apply style to all appearance of tags in a particular document. For example you are listing all the students and want to set color red only for students enrolled newly. In that case you have two choices

  1. Apply style to each new student item manually
  2. Create a class and apply to the new students. What advantage you get here is that if tomorrow you want to change color from red to blue, you will have to change only at one place.

You can either create class or Id. Both mark a certain element to refer then in style sheet.

image

You create a class as below,

image

And then you apply it to selection in document as below,

image

You create Id as below,

image

And then you apply it in document as below,

image

Below HTML summarize abut class and id


<!DOCTYPE html>
<html >
<head>
<title>
HTML5
</title>
<style>
.MyStyleClass
{
color:Red
}
#MyStyleId
{
font-size : 42px
}
</style>
</head>
<body>
<h1 id=MyStyleId >Hey I am ID </h1>
<h2>Hey I am Class 1</h2>
<h3>Hey I am Class 2</h3>
</body>
</html>

&nbsp;

On rendering you should get the output as below in the browser

image

 

This was all about Style Rules in HTML5. I hope this post is useful. Thanks for reading Smile

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

Query Methods in Roslyn Syntax API

In previous post I discussed about Roslyn Syntax API: First Look .

In pervious approach I traversed manually in Syntax Tree to the Method level and started from Compilation Unit level to get the Method Arguments. Rather than manually navigating the Syntax Tree, you can use LINQ to get the parameter in the function. We can directly apply LINQ on Syntax Tree.

image

If you remember from last post out Syntax Tree was as below,

clip_image001

Now if we want to print method name using LINQ in Syntax tree then,

clip_image003

Underneath LINQ is also doing the manual traversing of the Syntax tree. When you execute above code you will get output as below,

clip_image004

If you have more than one parameters in the method then you can print them like below,

clip_image006

And then you can traverse using foreach to print all the method names. For your reference all the code discussed in this post is given below,


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Roslyn.Compilers;
using Roslyn.Compilers.CSharp;

namespace ConsoleApplication30
{
class Program
{
static void Main(string[] args)
{

SyntaxTree tree = SyntaxTree.ParseCompilationUnit(
@"class Animal
{
void Display(string animalName,int abc)
{
Console.WriteLine(""Animal name is "" + animalName);
}
}");
var root = (CompilationUnitSyntax) tree.Root;

var paraMeterList = from r in root.DescendentNodes().OfType<MethodDeclarationSyntax>()
where r.Identifier.ValueText == "Display"
select r.ParameterList.Parameters.First();
Console.WriteLine(paraMeterList.Single().ToString());

var AllParaMeterList = from r in root.DescendentNodes().OfType<MethodDeclarationSyntax>()
where r.Identifier.ValueText == "Display"
select r.ParameterList.Parameters;
foreach (var r in AllParaMeterList)
{

foreach (var a in r)
{
Console.WriteLine(a.ToString());
}

}
Console.ReadKey(true);

}
}
}

&nbsp;

 

When you execute above listed code, you will get output as below,

clip_image001

In this way you can traverse Syntax tree using LINQ. I hope this post is useful. Thanks for reading Smile

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

Conditional Reading of Windows Azure BLOB

Conditional reading of BLOB implies, you want to read BLOB only when BLOB is modified. There are scenarios when you need to read BLOB frequently. In that case to avoid network usage and bandwidth, you may consider reading BLOB only when BLOB has been modified since last read or download. This type of BLOB reading is termed as Conditional BLOB reading.

Usually to read or download BLOB, you create reference of BLOB as below

image

In above code snippet

  1. ConnectionString is connection string to your storage account.
  2. Containername is name of the public container.
  3. Doc1.docx is name of the BLOB.

If you want to read it without any condition or in other words you want to read the BLOB regardless of whether it has been modified or not then you can read it in byte array as below,

image

As of now everything is fine for unconditional read but if you want to do Conditional read on the BLOB then you will have to use ,

  • IfNoneMatch
  •  eTag

IfNoneMatch is a static variable of AccessCondition structure. When you download a BLOB you can additionally provide BLOBRequestOptions. Almost all Download functions are overloaded with BlobRequestOptions.

image

If you don’t specify BLOBRequestOptions then you will perform unconditional read.

To perform conditional read, you need to follow below steps,

Step 1

Save ETag value from the server at time of first reading in a local variable

clip_image001

Step 2

Create instance of BLOBRequestOptions with setting AccessCondition as below,

clip_image001[6]

In above code we are passing locally saved ETag value to IfNoneMatch

 

Step 3

At time of making second call onward to download BLOB pass Request Option as below,

clip_image002

If BLOB is not modified then you will get into the Exception

At time of downloading BLOB in above code, server will fist check for the ETatg in IfNoneMatch header. If server don’t find new version, it will send HTTP 304 request to the storage library.

For your reference full source code of conditional BLOB reading is as below,


using System;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;

namespace ConsoleApplication7
{
class Program
{
static void Main(string[] args)
{

CloudStorageAccount account = CloudStorageAccount.
Parse("connectionString");

CloudBlobClient BlobClient = account.CreateCloudBlobClient();

CloudBlobContainer ContainerReference = BlobClient.
GetContainerReference
("dhananjay");

CloudBlob BlobReference = ContainerReference.
GetBlobReference
("Doc1.docx");

byte[] DownloadAsByteArray = BlobReference.DownloadByteArray();

var LastReadETag = BlobReference.Properties.ETag;

BlobRequestOptions RequestOption = new BlobRequestOptions
{ AccessCondition = AccessCondition.IfNoneMatch
(LastReadETag)
};

try
{
byte[] DownloadByteArraySecondTimeOnward = BlobReference.
DownloadByteArray(RequestOption);

}
catch (StorageClientException ex)
{
if (ex.StatusCode == System.Net.HttpStatusCode.NotModified)
{

}
}

}
}

}

&nbsp;

In this way you can perform conditional reading on Windows Azure BLOB. I hope this post is useful. Thanks for reading  Smile

 

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

Roslyn Syntax API: First Look

When BUILD was going on, I blogged ROSLYN: Complier as Service?

Recently Microsoft released Roslyn CTP and you can download it from here. You can learn more here

In this post, I will focus on Roslyn Syntax API.

Syntax Tree is used by the compiler to understand the language constructs.

image

Syntax Tree exposed by Roslyn Syntax API is immutable. So to use it as a developer you can consume it on multiple threads without much thinking about concurrency measures and all.

Essentially; Roslyn Syntax API exposes below classes.

image

Let us now explore each of classes and structure exposed by Roslyn Syntax API one by one. Create a Roslyn Console Application. Once you install Roslyn CTP, you will get Roslyn project template installed. Choose Console Application from installed template.

image

Let us create a compilation unit called Animal. We will pass this class to create syntax tree and do the evaluation.

clip_image002

You can pass class Animal as string to SyntaxTree class

clip_image004

Have you noticed two times double quotes before Animal in print statement Smile

If you execute below statement you will find returned syntax tree is the compilation unit.

clip_image005

Variable tree is the instance of SyntaxTree class.

Expected Output

clip_image006

Typecast returned root to CompilationUnitSyntax and put a breakpoint to analyze more what Roslyn syntax API returns .

clip_image008

You will notice there are 0 counts in using directive since we are not having any using directive in the input text (Animal class) to the SyntaxTree ParseCompilation. In count of Member you will find 1.

clip_image010

To get the First member you need to fetch it as you are fetching usual array with the index value.

clip_image011

In our case we have only one member and that is Animal class. So first print statement will print the class and second statement will print the type that is Class Declaration.

Expected Output

clip_image012

Since kind of member is ClassDeclaration so typecast it to ClassDeclaration to evaluate it more.

clip_image014

And if you put breakpoint and execute it you will find there are Members, Keywords, and Identifier etc. for ClassDeclarationSynatx also. Count value for Members is 1. This value is 1 because there is one function in Animal class.

clip_image016

When you print kind of FirstMethod as below,

clip_image017

Expected Output

clip_image018

Put breakpoint on FirstMethod variable, you will find number of parameters count to 1. In Animal class , Display method has one input parameter.

clip_image020

To print input parameter you need to traverse the syntax tree as below

clip_image022

Expected output

clip_image023

In this way you can harness all the capability and features of Roslyn Syntax API to do reverse engineering on your code. For your reference all the source code discussed in this article is given below.


using System;
using Roslyn.Compilers.CSharp;

namespace ConsoleApplication30
{
class Program
{
static void Main(string[] args)
{

SyntaxTree tree = SyntaxTree.ParseCompilationUnit(
@"class Animal
{
void Display(string animalName)
{
Console.WriteLine(""Animal name is "" + animalName);
}
}");
var root = (CompilationUnitSyntax) tree.Root;
var FirstMember = root.Members[0];
Console.WriteLine(FirstMember.ToString());
Console.WriteLine(FirstMember.Kind.ToString());
var FirstMemberAsClass = (ClassDeclarationSyntax)FirstMember;
var FirstMethod = (MethodDeclarationSyntax) FirstMemberAsClass.Members[0];
Console.WriteLine(FirstMethod.Kind.ToString());
var FirstMethodParameter = FirstMethod.ParameterList.Parameters[0];
Console.WriteLine(FirstMethodParameter.ToString());
Console.ReadKey(true);
}
}
}

On running the above code you will get consolidated output as below,

clip_image002[6]

I hope this post is useful to you. Thanks for reading  Smile

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.