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

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Interview Question >> C# >> Post New Question Subscribe to Interview Questions

How do you call a Member method and pass a value Type by reference?

Posted By :Narayanan     Posted Date :November 21, 2011    Points :40   Category :C# 
use the "ref" keyword when declaring a Parameter of the Method
public bool GetValue(ref int returnvalue);

You can also find related Interview Question to How do you call a Member method and pass a value Type by reference?  below: 

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

How do you call a Member method and pass a value Type by reference?

use the "ref" keyword when declaring a Parameter of the Method (More...)

Can we call a base class method without creating instance?

Its possible If its a static method.

Its possible by inheriting from that class also.

Its possible from derived classes using base keyword. (More...)

How can you reference current thread of the method ?

"Thread.CurrentThread" refers to the current thread running in the method."CurrentThread" is a public static property. (More...)

Value type & reference types difference? Example from .NET. Integer & struct are value types or reference types in .NET?

Most programming languages provide builtin data types, such as integers and floatingpointnumbers, that are copied when they are passed as arguments (that is, they are passed by value). In the .NET Framework, these are called value types. The runtime

supports two kinds of value types:
· Builtin
value types
The .NET Framework defines builtin
value types, such as System.Int32 and
System.Boolean, which correspond and are identical to primitive data types
used by programming languages.
· Userdefined
value types
Your language will provide ways to define your own value types, which derive from System.ValueType. If you want to define a type representing a value that is small, such as a complex number (using two floatingpoint numbers),
you might choose to define it as a value type because you can pass the value type efficiently by value. If the type you are defining would be more efficiently passed by reference, you should define it as a class instead.

Variables of reference types, referred to as objects, store references to the actual data. This following are the reference types:
· class
· interface
· delegate
This following are the builtin
reference types:
· object (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...)

Which method would you call to send an e-mail message and wait for the transmission to complete before proceeding?

Select from following answers:


Correct Answer is:

SmtpClient.Send (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...)

How to pass a value from a method to a property procedure in c# win application?

Here is my code:

class Jewellery : Connectionstr

string lmcode;

public string LM_code//Here i want to access the value of the method(ReadData) i.e displaystring and store the value in to the insert query below.
get { return lmcode; }
set { lmcode = value; }


string mname;
public string M_Name
get { return mname; }
set { mname = value; }

string desc;
public string Desc
get { return desc; }
set { desc = value; }

public string ReadData()
OleDbDataReader dr;
string jid = string.Empty;
string displayString = string.Empty;
String query = "select max(LM_code)from Master_Accounts";
Datamanager.RunExecuteReader(Constr, query);

if (dr.Read())
jid = dr[0].ToString();
if (string.IsNullOrEmpty(jid))
jid = "AM0000";
int len = jid.Length;
string split = jid.Substring(2, len - 2);
int num = Convert.ToInt32(split);
displayString = jid.Substring(0, 2) + num.ToString("0000");
return displayString;//I want to pass this value to the proeprty proc above i.e LM_code.

public void add()

String query ="insert into Master_Accounts values ('" + LM_code + "','" + M_Name + "'," + "'" + Desc "')";
Datamanager.RunExecuteNonQuery(Constr , query);

} (More...)

what is the difference between value type and reference type?

Value type is stored in stack.
Reference type stored in heap. (More...)

Is array reference type / value type?

Array is a reference type and it is stored in Heap memory!

Reference types are:


Is string reference type / value type?

string is reference type
because String is immutable objects..........
means does not change the values(string)....... (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