| Back to Questions Page |
| Question |
what is reference parameter?
what is out parameters?
what is difference these two? |
Rank |
Answer Posted By |
|
Interview Question Submitted By :: Somavenki |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer |
a ref parameter must first be initialized before being
passed from the calling function to the called function.
but a out parameter need not be initialized, we can pass it
directly  |
1 | Anna |
| |
| |
| Answer |
normally while we are passing values to other methods it
will pass copy of the values.But we use ref or out
parameter it pass reference of values.  |
1 | Aravazhi [Hasten Technologies] |
| |
| |
| Answer |
When we pass a parameter as ref to a method, the method
refers to the same variable and changes made will affect
the actual variable. even the variable passed as out
parameter is same as ref parameter, but implementation in
c# is different,
Arguement passed as ref parameter must be initialized
before it is passed to the method. But in case of out
parameter it is not necessary. But after a call to a method
as out parameter it is necessary to initialize.
When to use out and ref parameter, out parameter is used
when we want to return more than one value from a method.  |
2 | Lakshmi [Hasten Technologies] |
| |
| |
|
|
| |
| Answer |
Ref parameter can be used as both input and o/p parameter
out parameter can be used as only output parameter  |
0 | Rvs Varma [Hasten Technologies] |
| |
| |
| Answer |
The main difference between them is ref parameter act as
input/output whereas out parameter is simply act as output.
Let us understand with an example:
Out parameters "out" parameters are output only parameters
meaning they can only passback a value from a function.We
create a "out" parameter by preceding the parameter data
type with the out modifier. When ever a "out" parameter is
passed only an unassigned reference is passed to the
function.
using System;
class Test
{
static void out_test(out int x)
{
x=100;
}
static void Main()
{
int Myvalue=5;
MyMethod(Myvalue);
Console.WriteLine(out Myvalue);
}
}
Output of the above program would be 100 since the value of
the "out" parameter is passed back to the calling part.
Note
The modifier "out" should precede the parameter being
passed even in the calling part. "out" parameters cannot be
used within the function before assigning a value to it. A
value should be assigned to the "out" parameter before the
method returns.
Ref parameters "ref" parameters are input/output parameters
meaning they can be used for passing a value to a function
as well as to get back a value from a function.We create
a "ref" parameter by preceding the parameter data type with
the ref modifier. When ever a "ref" parameter is passed a
reference is passed to the function.
using System;
class Test
{
static void Mymethod(ref int x)
{
x=x+ 100;
}
static void Main()
{
int Myvalue=5;
MyMethod(Myvalue);
Console.WriteLine(ref Myvalue);
}
}
Output of the above program would be 105 since the "ref"
parameter acts as both input and output.
Note
The modifier "ref" should precede the parameter being
passed even in the calling part. "ref" parameters should be
assigned a value before using it to call a method.  |
3 | Piyush Sharma [Hasten Technologies] |
| |
| |
| Answer |
out -doesnot keep initial value or assigned value.
ref-does
void f1(out int t){
t+=100 //give error becs t has no value --true for ref
t=100 //possible
}  |
0 | Vijaysaxena [Hasten Technologies] |
| |
| |
| Question |
from web.config file with connection string who to interact
means who to connect in gridview. in my system shows null
something error what is the problem |
Rank |
Answer Posted By |
|
Interview Question Submitted By :: Somavenki |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer |
from web.config file with connection string who to interact
means who to connect in
gridview. in my system shows null something error what is
the problem  |
0 | Saminathan |
| |
| |
| Answer |
The name of the default table adapter connection string
looks something like the following:
AppName.Settings.Default.ConnectionStringName
Naturally, AppName is the name of your application and
ConnectionStringName is the name you've given to your
connection string. This is the 'certain way' that Jay is
talking about.
If you create a TableAdapter through the design time
interface and configure the connection string to save into
the config file, you can edit the config file and see
exactly what connection string name is expected.  |
0 | Samy [Hasten Technologies] |
| |
| |
| Question |
what is collections and
what is generics |
Rank |
Answer Posted By |
|
Interview Question Submitted By :: Somavenki |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer |
collections includes of arraylist and hashtables which are
similar to arrays but arrays we cant perform delete and add
operations whereas in collections it is possible some
addmethods are available  |
0 | Ilangkumaran |
| |
| |
| Answer |
collection in case of memory useful .its size is not
fixed,means the if we want to store data more than its
default size its automatically double its default size.but
in case of normal array we can do through redim also the
memory allocated is new[impact on the performance].  |
0 | Ashwani Kumar [Hasten Technologies] |
| |
| |
| Answer |
COLLECTION:
Collection are used for grouping related objects that
allows us to iterate over those objects.
Generics:
Generic means make objects generalise.Generic types are the
types that take other type name to define their own type.  |
0 | Osheen [Hasten Technologies] |
| |
| |
|
| |
|
Back to Questions Page |