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


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> ADO.Net >> Post New Question Subscribe to Interview Questions

Which keyword is used to accept variable number of parameters?

Posted By :Bhumika Patel     Posted Date :March 07, 2013    Points :40   Category :ADO.Net 


Params keyword is used to accept variable number of parameters.



You can also find related Interview Question to Which keyword is used to accept variable number of parameters?  below: 

HOW TO ASSIGN VALUE TO PARAMETERS USED IN QUERY WHICH IS STORED IN A VARIABLE?

  
Have a look at the following sql block

DECLARE
/* @STRQUERY AND @PARAMDEF SHOULD BE NVARCHAR
BECAUSE "EXECUTE sp_executesql" ACCEPTS STATEMENT AND PARAMETER OF TYPE 'ntext/nchar/nvarchar' ONLY
OTHERWISE
"Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'."
OR
"Procedure expects parameter '@parameters' of type 'ntext/nchar/nvarchar'." WILL BE RAISED*/
@STRQUERY AS NVARCHAR(200),
@STRNAME AS VARCHAR(100),
@PARAMDEF AS NVARCHAR(100),
@STRNAMEVALUE AS VARCHAR(100)
BEGIN
--FOLLOWING STATEMENT ASSING VALUE
SET @STRNAMEVALUE='MANINDER'
--FOLLOWING VARIABLE CONTAINS A QUERY WHICH USES A PARAMETER
SET @STRQUERY = 'SELECT ''YOUR NAME IS '' + @STRNAME'

--FOLLOWING STATEMENT DEFINES THE PARAMETERS USED IN THE QUERY
SET @PARAMDEF = '@STRNAME AS VARCHAR(100)'

--IN THE FOLLOWING STATEMENT "@STRNAME = @STRNAMEVALUE" STATEMENT ASSIGNS VALUE TO THE PARAMETER
--SYNTAX IS EXECUTE sp_executesql @STATEMENT, @PARAMETERS
EXECUTE sp_executesql @STRQUERY, @PARAMDEF,@STRNAME = @STRNAMEVALUE;
END (More...)

Does C# support a variable number of arguments

  
Yes, using the params keyword.

The arguments are specified as a list of arguments of a specific type, e.g., int. For ultimate flexibility, the type can be object.

The standard example of a method which uses this approach is System.console.writeLine(). (More...)

What is the difference between ref & out parameters?

  
An argument passed to a ref parameter must first be initialized. Compare this to an out parameter, whose argument does not have to be explicitly initialized before being passed to an out parameter. (More...)

Minimum number of queues needed to implement the priority queue?

  
Two. One queue is used for actual storing of data and another for storing priorities. (More...)

What is Version Number in Assembly Manifest ?

  
A revision and build number in an assemblies is called Version Number.

There are Major and Minor Version number in an assembly. you can change this version number in assemblyinfo.cs file
usually version number looks like this in assemblyinfo.cs
1.0.*

The common language run time uses these numbers to enforce version policy. (More...)

Yield keyword in C Sharp

  
C Sharp and yield keyword

Hi,



One of the cool and yet most unknown feature of the C# is the yield keyword. The yield keyword is used in an iterator block to provide a value to the enumerator object or to signal the end of the iteration. When used the expression is evaluated and returned as a value to the enumerator object. Note the expression has to be implicitebly convertible to yield type of the iterator. Here is an example



public static IEnumerable GetIntCollectionFromString(string SomeString){ string[] val = SomeString.Split(' '); int intToAdd; foreach (string token in val) { if (int.TryParse(token, out intVal)) { yield return intVal; } else { yield break; } }}

Here since we are using the yield keyword the function will return the collection of intVal instead of the value of intVal. The statement will only return when the iteration of the loop is complete.



There are some limitation with the yield keywords.

Unsafe blocks are not allowed
Parameters to the method, operator, or accessor cannot be ref or out. (More...)

How to get IP Number of a SYSTEM?

  
Request.UserHostAddress.ToString();
(or)
Request.UserHostName.ToString(); (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