.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 >> C# >> Post New Question Subscribe to Interview Questions

How do I simulate optional parameters to COM calls?

Posted By :nishithraj     Posted Date :November 30, 2009    Points :10   Category :C# 
You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have optional parameters.

You can also find related Interview Question to How do I simulate optional parameters to COM calls?  below: 

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...)

what is the difference between ref and out parameters ?

  
Argument passed as ref must be initialized before it is passed to the method,where as incase of Out it's not neccssary.but after a call to the method as an out parameter the variable must be initialized .out parameter can be used when you want to return more than one value from a method. (More...)

can a constructor have parameters?

  
Yes, constructor can have parameters of their own.

also it can be overloaded.

public class myClass
{
public myClass()
{
// This is the no parameter constructor method.
// First Constructor
}

public myClass(int EmpID)
{
// This is the constructor with one parameter.
// Second Constructor

}

public mySampleClass(int EmpID, string Name)
{
// This is the constructor with two parameters.
// Third Constructor
}

(More...)

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...)

What is Optional Explicit in VB.net ?

  
When a variable is assigned with Option Explicit the variable must and should be declared .

Use Option Explicit to avoid incorrectly typing the name of an existing variable or to avoid confusion in code where the scope of the variable is not clear. If you do not use the Option Explicit statement, all undeclared variables are of Object type.

Usage : Option Explicit On
(More...)

Parameters used in Connection pooling

  
Connection Pooling is controlled and the parameters passed to a connection string comprises the following:

· Connect Timeout

· Min Pool Size

· Max Pool Size

· Pooling

(More...)

Why do we need "out" parameters?

  
we need out parameters because it enforce the contract between the caller and the callee (the function being called) by explicitly specifying that the callee will initialize them. (More...)

What is Difference between ref and out parameters in c#

  
A ref parameter:
has to be initialized by the caller.
does not have to be assigned in the function.
a ref parameter is for both input and output to the method

An out parameter:
does not have to be initialized by the caller.
has to be assigned in the function
an out parameter is only for output. (More...)

What are the Parameters used in Connection pooling

  
nnection Pooling is controlled and the parameters passed to a connection string comprises the following:

· Connect Timeout

· Min Pool Size

· Max Pool Size

· Pooling

(More...)

Can we pass optional argument to function in VBScript?

  
Yes, We can pass optional argument to VBScript functions.We can use optional argument in VBScript by specifying optional keyword. (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