.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Interview Question >> LINQ >> Post New Question Subscribe to Interview Questions

What is the method to convert one type to another using Lambda expressions?

Posted By :Jean Paul     Posted Date :May 11, 2011    Points :40   Category :LINQ 
Select() method

You can also find related Interview Question to What is the method to convert one type to another using Lambda expressions?  below: 

How do I convert a numeric type to a string?

Call Sytem.Object.ToString(). For example, if the variable count is an integer, write the following:
string text = count.ToString(); (More...)

How do I call a member method and pass a primitive type (Value Type) by reference?

Use the ref keyword when declaring the parameter of the method, for example:

public bool GetValue( ref int returnValue );

This will pass the numeric by reference.You can modify the value of returnValue within the body of GetValue and it will persist when the method call returns. (More...)

convert a value-type to a reference type is known as?


Boxing is the terminology used in .NET Framework to convert Value type to reference type (More...)

convert a Reference Type to a Value type is known as?


UnBoxing is the terminology used in .NET Framework to convert Reference Type to a Value type (More...)

Why do I get an error (CS1006) when trying to declare a method without specifying a return type?

If you leave off the return type on a method declaration, the compiler thinks you are trying to declare a constructor. So if you are trying to declare a method that returns nothing, use void. The following is an example: // This results in a CS1006 error public static staticMethod (mainStatic obj) // This will work as wanted public static void staticMethod (mainStatic obj) (More...)

What is the difference between Convert.toString and .toString()

Just to give an understanding of what the above question means see the below code :-

int val = 0;

We can convert the integer "val" using "val.ToString()" or "Convert.ToString" so what's the difference.

The basic difference between them is "Convert" function handles NULLS while "val.ToString()"
does not.

It will throw a NULL reference exception error. So as good coding practice using "Convert" is always safe. (More...)

What is the difference between Convert.ToString() and .ToString() method.

Have a look at the following program and its output

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExampleOfString
class Program
static void Main(string[] args)
String UserName = null ;
//Below statement WILL THROW an exception as .ToString() does not handles null values
String strUserId = UserName.ToString();
catch (NullReferenceException ex)
Console.WriteLine("Error:{0}", ex.Message);

//Below statement WILL NOT THROW an exception as convert.tostring handles implicitly
String strUserId = Convert.ToString(UserName);
Console.WriteLine("UserName:{0}", strUserId);
catch (NullReferenceException ex)
Console.WriteLine("Error:{0}", ex.Message);

Below is the output of the console application

Error:Object reference not set to an instance of an object.
Press any key to continue . . .
*/ (More...)

What is lambda expressions

A lambda expression is an unnamed method written in place of delegate instance.It has th following form

(Parameter => expression or state,ent block.
eg: y=>x*x;

How to find the index of element using Where() with Lambda Expressions?

Use the two argumented Lambda method

Where((i, ix) => i == ix); (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend